This sample demonstrates how trigonometry and pythagorean theorem work, which are essencial to deal with distances and angles in 2D or 3D space. Try dragging the point P.
Pythagorean theorem
OP = Math.sqrt(handle.x * handle.x + handle.y * handle.y);
Trigonometry
sin(AOC) = AC;
cos(AOC) = OC;
sin(AOC) = AC / OC;
note that the direction of the Y-coordinate in Flash is opposite of Cartesian coordinates.
See 'Trigonometry - Wikipedia' for more about trigonometry and 'Pythagorean theorem - Wikipedia' for Pythagorean theorem.
sample movie and scripts



Leave a comment