C# Trig Point To Point Angle (Yaw) Question

rover2341

Is riding a roller coaster...Wee!
Reaction score
114
Edit**

SOLVED


I have a XY Point (Start) And a XY Point (End)

I am trying to get the YAW Between them or the angle between them.
HUKbR.png


I want the THICK RED Angle. So that would be around 290 or so.

I have been using this. But It doesent always work.
REF: http://stackoverflow.com/questions/...-angle-between-a-line-and-the-horizontal-axis

Code:
 float x = XPosition - tracks.Last().Position.X;
float y = YPosition - tracks.Last().Position.Y;


yawGoal = Math.Abs(Convert.ToSingle(Math.Atan2((double)x, (double)y) * 180 / Math.PI));


//These Work But

F-B FAILS (Comes up with 115, That is a good angle, But in my project it gos Stright Right...)
G-B FAILS (Comes up with 115, That is a good angle, But in my project it gos Stright Right...)

Points.png


Any thoughts?

Edit*

Looks like Mine Game is setup....

not 0-90-180-270
but 90-180-270-0

Hmm.. But something is wack maybe my axis is reverse too..

Edit**

SOLVED

Code:
                if (XPosition < tracks.Last().Position.X)
                    yawGoal = yawGoal + 90;

this fixed it.
 
Last edited:
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top