JavaScript Trigonometry


Example

All angles below are in radians. An angle r in radians has measure 180 * r / Math.PI in degrees.

Sine

Math.sin(r);

This will return the sine of r, a value between -1 and 1.

Math.asin(r);

This will return the arcsine (the reverse of the sine) of r.

Math.asinh(r)

This will return the hyperbolic arcsine of r.

Cosine

Math.cos(r);

This will return the cosine of r, a value between -1 and 1

Math.acos(r);

This will return the arccosine (the reverse of the cosine) of r.

Math.acosh(r);

This will return the hyperbolic arccosine of r.

Tangent

Math.tan(r);

This will return the tangent of r.

Math.atan(r);

This will return the arctangent (the reverse of the tangent) of r. Note that it will return an angle in radians between -π/2 and π/2.

Math.atanh(r);

This will return the hyperbolic arctangent of r.

Math.atan2(x, y);

This will return the value of an angle from (0, 0) to (x, y) in radians. It will return a value between and π, not including π.