Java Script Math.sin Method
By Stephen Bucaro
Sine is a trigonometric function. Based on a right triangle. It's the ratio of the length
of the opposite side to the length of the hypotenuse.
sine A = opposite/hypotenuse
In identifying the sides of a right triangle, the side next to the angle for which we
are using the trigonometric function is called the adjacent side. The side opposite that
angle is called the opposite side.
If you know an angle and the length of the side opposite the angle, you can
use the sine of the angle to calculate the length of the hypotenuse.
length of hypotenuse = length of opposite/sine of angle
angle = 40 degrees
opposite side = 9
Java Script Using Math.sin Method
var angle = 40;
var opposite = 9;
var hypotenuse = opposite/Math.sin(40 * Math.PI/180);
The code shown above uses the Java Script Math.sin method. The Math.sin method requires
the angle passed to it to be in radians. A radian is the angle of an arc created by
wrapping the radius of a circle around its circumference. It sounds like a weard unit, by
by coincidence there are 2 PI radians in a complete circle. This makes this much easier in
fields like calculus. To convert degrees to radians, multiply by PI/180.
The code shown above also uses the Number objects .toFixed(n) method. This method
converts a value to a number with n digits to the right of the decimal point.
More Java Script Code:
• The for Loop
• The Browsers History Object
• Java Script Number Object
• Determine Absolute Value
• Java Script prompt Message Box
• Cookie Power Made Easy
• The if/else Structure
• Java Script Trigonometric Methods
• Get Webpage File Date and File Size