------------------------------------- | P2={X2,Y2} | / | / | / | / | / | / alpha | / ............. | P1={X1,Y1} |
math.atan2(Y2-Y1,X2-X1)
alpha
This works perfectly for me const double Rad2Deg = 180.0 / Math.PI; const double Deg2Rad = Math.PI / 180.0; /// <summary> /// Calculates angle in radians between two points and x-axis. /// </summary> private double Angle(Point start, Point end) { return Math.Atan2(start.Y - end.Y, end.X - start.X) * Rad2Deg; }
Atan2
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)