July 25, 2000 - Animation with Math.sin()
July 25, 2000|
Animation with Math.sin()
Tips: July 2000
Yehuda Shiran, Ph.D.
Math.sin()method accepts one argument (an angle in radians) and returns its sine value. The following statement prints "1":
document.write(Math.sin(0.5 * Math.PI));
Math.sin() method is useful in animation applications. If an object A revolves around object B in a constant radius orbit, its x location can be derived by multiplying the orbiting raidus by the sine of the angle that the radius makes with the upright ray.
Math.asin()method accepts one argument and returns the arc sine (the angle that the given number is its sine value) of the argument, in radians. The following statement prints the value of PI:
document.write(2 * Math.asin(1));