In development, it is sometimes necessary to compute the angle between a vector of two coordinate points and an axis, and then we use the results to rotate the component (rotation). The following shows the calculation method for the angle between the x axis and the y axis respectively.
1, the angle of the x axis
var p1:point = new Point (40,30);
var p2:point = new Point (80,60);
var angle:number = math.atan2 ((p2.y-p1.y), (p2.x-p1.x))//Radians 0.6435011087932844
var theta:number = angle* (180/MATH.PI); Angle 36.86989764584402
2, the angle of the Y axis
The calculation method is similar to the x-axis angle, except that the x and Y coordinate positions in the parameters are reversed when the radian is calculated.
var p1:point = new Point (40,30);
var p2:point = new Point (80,60);
var angle:number = math.atan2 ((p2.x-p1.x), (P2.Y-P1.Y))//Radians 0.9272952180016122
var theta:number = angle* (180/MATH.PI); Angle 53.13010235415598