Angle Between 2 Points In ActionScript

BlueSin

New Member
Reaction score
37
Yes this is probably a very stupid question, but I never paid attention in trigonometry. How do you find the angle between two points in ActionScript (Flash programming language)?

If you're unfamiliar with ActionScript, how do you find the angle between two points in general?

EDIT: I wasn't sure if this was the right sub-forum, since there isn't a 'programming in general' sub-forum.
 

mase

____ ___ ____ __
Reaction score
154
Lol, since there is no 'programming in general' forum you should have just posted it in general discussion xD

lol here is how:
Code:
Xdiff = _root._xmouse-this._x;
Ydiff = _root._ymouse-this._y;
radAngle = Math.atan2(Ydiff, Xdiff);
this._rotation = int((radAngle*360/(2*Math.PI))+180);
angle = (this._rotation*(Math.PI/180));

-Edit-
Here is a flash I made a while ago messing with a code like that.
http://img45.imageshack.us/my.php?image=followthemouse9lr.swf
 
V

Vector

Guest
Or something a little more consolidated such as
Code:
var angle:Number = Math.atan2(y2 - y1, x2 - x1) * 180 / Math.PI;

Given x1 and y1 is "the point you're standing at" and x2 and y2 is "the point that you want to be looking towards".
 
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