ID:1625105
 
Keywords: angle, compass, rotation
(See the best response by Ter13.)
I want to create a compass-like pointer with use of atom.transform and all that, but I'm not entirely sure what kind of calculations are needed to determine what rotation I'll need to rotate an arrow to point directly at a goal destination.

To be more specific, my goal is to be able to simply ask "I have an object at 1,1 on a grid, what angel does it need to rotate to point at an object that is at 10,15 on the grid." and other similar situations.

I'm sure this is something I should had learned in geometry in school but what can I say, I'm a dropout.
Its just some mathematics that needs to be used, a great start is looking at Kid Paddle's version.

You know already that a circle/rotation can go for a maximum of 360 degrees before starting over. (Co-Terminal Angles)

You would want to get the posion of object1 and object 2 and use some math to calculate the angle to turn the compass's arrow towards.

A great example could be found here:

http://www.byond.com/developer/Kidpaddle45/Compas
Best response
Create a triangle with the points:




         10,15
/|
/ |
/ | Adjacent
/ |
/____|
1,1 10,1


The length of the sides is:
Opposite: 10
Adjacent: 15
Hypotenuse: 18.02775 ( sqrt(O**2+A**2) )

SohCahToa

sin = opposite/hypotenuse
cos = adjacent/hypotenuse
tan = opposite/adjacent

xrot = 10/18.02775
yrot = 15/10.02775


If you don't know basic trig, go no further.
Thanks for the reference and the math, both are exceedingly helpful! :D