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.
ID:1625105
|
|
Create a triangle with the points:
10,15 The length of the sides is: Opposite: 10 Adjacent: 15 Hypotenuse: 18.02775 ( sqrt(O**2+A**2) ) SohCahToa sin = opposite/hypotenuse If you don't know basic trig, go no further. |
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