Fri 20 Mar 2009

Flash and ALL programs working with 2D space like canvas in Photoshop or Illustratror use trigonometry. If you want to make quality motion scripts in 2D or 3D you cant do it without trigonometry. Here I will describe the basics of trigonometry and present the most important basic formulas.

Trigonometry is a branch of mathematics which is specialised in triangles. Why a flasher could need triangles? As you know the flash space is organized by two values - X and Y . And if you will divide the space or work canvas in flash by two imaginary lines you will get four big triangles, as it showed at first picture:

As you see the angle of every one of this triangle that is clos to coordinate O has 90° . Triangles with an angle of 90° are called right triangles. The proportions between angles and sides in right triangles can be described in specific formulas that are used by trigonometry.

Trigonometry uses some specific termins, like cathets, which are commonly called legs, and hypotenuse. Legs of an triangle are sides close to the 90°angle and the hypotenuse is side opposite to the 90°angle. You can see this in the picture above.

Im shure all of you know the rule of Pythagore that says ” in a right triangle the square of hypotenuse equals to sum of the squares of legs “. Here is the formula hypotenuse²= firstleg² + secondleg² . This formula works always and if you need to find a side’s length and you know lengths of other two sides you got the method to do it.

Other specific termins of trigonometry are sine, cosine, tangent, arcsine, arccosine, and arctangent.

The sine of an angle is the ratio of the angle’s opposite leg to the hypotenuse.

Cosine is defined as the ratio of the adjacent leg of an angle to the hypotenuse.

Tangent is the relationship of the opposite leg to the adjacent leg.

Arcsine, arccosine and arctangent are opposites of the sine, cosine and tangent. For example if you have the sine of an angle but you dont know the angle and want to find it you can use the formula:

angle = arccos ( amount of cos of the angle )

Remember that in AS3.0 the Math class uses radians in place of degrees. Radians are units of measurment used in trigonometry and the relationship between angles and radians is that 360 degrees equal to 2 * π radians. This way one radian equals to π / 180 degrees.

The trigonometry posess many other formulas and usefull features and I will show some of them in next posts. Those who want to dig deeply in trigonometry can use materials like this link.

your advice was very helpful. I needed this information for a class assignment and never thought of using trig in design programs. Thanks again so much for posting this, huge help!