ActionScript 3 Working with Geometry Getting the angle between two points

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

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.



Got any ActionScript 3 Question?