Results 1 to 11 of 11

Thread: [RESOLVED] [C#] Getting the angle from origin to a point on x, y axis.

Threaded View

  1. #6

    Thread Starter
    coder. Lord Orwell's Avatar
    Join Date
    Feb 2001
    Location
    Elberfeld, IN
    Posts
    7,628

    Re: any good online sites to refresh trigonometry?

    i finally solved this. There was a code sample on a yahoo answers page that i started with, and after i corrected the three glaring errors in it, i rotated the axis and fixed it to make a 0-359 degrees with vertical top being 0.
    C# Code:
    1. Vector2 diff = new Vector2(mx, my);
    2.            Rotation = Math.Asin(1 * diff.Y / diff.Length());
    3.             Rotation = Math.PI / 2 + Rotation;
    4.            if (diff.X < 0.0)
    5.            {
    6.                Rotation = MathHelper.ToRadians(360) - Rotation;// Rotation * -1;
    7.            }
    Last edited by Lord Orwell; Mar 4th, 2011 at 12:05 AM.
    My light show youtube page (it's made the news) www.youtube.com/@lightsofelberfeld
    Contact me on the socials www.facebook.com/lordorwell

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width