Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8066363
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T11:58:10+00:00 2026-06-05T11:58:10+00:00

Is there a code formula for this? I am using C# and XNA, and

  • 0

Is there a code formula for this? I am using C# and XNA, and in my class I have an array of three vectors (representing the vertices of the triangle), as well as a separate vector coordinate.

I plan to update these positions in the loop as it escalates further towards the top of the screen.

I’d ask maths.stackexchange.com, but seeing as how this applies to programming (and I personally am better at reading code as opposed to math itself – I’m still taking Algebra in school), I think it would make more sense for me to ask it here.

Edit
Yes, I am looking for an equilateral triangle. Or any triangle, for that matter. It doesn’t matter what it is. All I am looking for is a formula; is that so hard to ask for?

Teh Problem

Basically, the problem I am trying to solve is to shoot a triangle out of my player (think Space Invaders; i.e., the triangle acts as a ray from the ray gun). What I need is a formula of code which will allow the triangle to be rendered based on its center position and radius, as the triangle will move upwards on its Y coordinate. I have the draw calls, and they work, but the problem is that the triangle when put in a for loop draw iteration (where the center vector position – on the Y coordinate – is incremented by N) simply sits next to the player’s position when being drawn.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T11:58:15+00:00Added an answer on June 5, 2026 at 11:58 am

    I think this is what you are looking for…
    the angle is the orientation of the triangle…
    this build a triangle….

    void BuildTriangle(Vector2 Center, float Radius, float Angle, Vector2[] tri)
    {
       for (int i=0; i<3; i++)
       {
          t[i].X = Center.X + Radius * (float) Math.Cos(Angle + i * 2 * MathHelper.PI/3);
          t[i].Y = Center.Y + Radius * (float) Math.Sin(Angle + i * 2 * MathHelper.PI/3);
       }
    }
    

    if you want to move it, add to the center a velocity vector and rebuild it…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In a .f file there is code that does this: real Bob, avar ...
I am using this code to calculate the the distance between two points. I
This is the code that works, locally. $str = <<<SSS <H1 class=prodname>Alison Raffaele Reality
I'm using this code block to get the font name, style and size selected
There is code for save button, but I can't see any code behind the
In my code there are a lot of final values, like 10000. They never
Is there any code or custom options available to achieve the following : 1>
In the code there exists exactly one type that implements IResourceConverter. That's what the
In my code there are some calls to a method that set the values
Is there any code example teaching how to zoom in and out in a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.