ActionScript for Flash MX: The Definitive Guide, Second Edition

ActionScript for Flash MX: The Definitive Guide, 2nd EditionBy Colin Moock
Chapter 18.  ActionScript Language Reference
Math.sin( ) Method Flash 5; can be used when exporting Flash 4 movies

compute the sine of an angle

Math.sin(theta)

Arguments

theta

An angle, in radians (not degrees), normally in the range of 0 to 2, although any angle will suffice, as sine is a periodic function.

Returns

The sine of theta (the result is in the range of -1.0 to 1.0).

Description

The sin( ) method returns the trigonometric sine of an angle. In a right triangle, the sine of an angle is the result of dividing the length of the side opposite the angle by the triangle's hypotenuse.

Usage

Note that sin( ) expects angles to be provided in radians, not degrees.

Example

trace(Math.sin(0)); // Displays: 0 trace(Math.sin(Math.PI/2)); // Displays: 1.0

The sin( ) function can be used along with cos( ) to calculate a point on a circle. See the Example under Math.cos( ).

See Also

Math.asin( ), Math.cos( ), Math.PI, Math.tan( )

    Категории