ActionScript 3 Working with Geometry Getting the angle between two points


Example

Using vanilla mathematics:

var from:Point = new Point(100, 50);
var to:Point = new Point(80, 95);

var angle:Number = Math.atan2(to.y - from.y, to.x - from.x);

Using a new vector representing the difference between the first two:

var difference:Point = to.subtract(from);

var angle:Number = Math.atan2(difference.y, difference.x);

Note: atan2() returns radians, not degrees.