Trigonometry
Following are the trigonometric functions in Chelsea.js
All the functions are briefly explained with pure mathematical formulae , examples and implementation.
Sine
Sine of an angle is the length of the line joining the x-axis and the point on the unit circle at the same angle.
sin(angle);
sin(0); // returns 0
sin(PI/2); // returns 1
Graphical representation of the above function:
Cosine
Cosine of an angle is the length of the line joining the y-axis and the point on the unit circle at the same angle.
cos(angle);
cos(0); // returns 1
cos(PI/2); // returns 0
cos(PI); // returns -1
Graphical representation of the above function:
Tangent
Tangent of an angle is the slope of the line joining the origin and the point on the unit circle at the same angle.
tan(angle);
tan(0); // returns 0
tan(PI/2); // very large value since js doesnt return Infinity for Math.tan(PI/2) and these math functions are mere implementation of Math in js.
Arc Sine
Arc Sine of an angle is the angle whose sine is the given value.
asin(value);
asin(0); // returns 0
asin(1); // returns PI/2
asin(-1); // returns -PI/2
Arc Cosine
Arc Cosine of an angle is the angle whose cosine is the given value.
acos(value);
acos(0); // returns PI/2
acos(1); // returns 0
acos(-1); // returns PI
Arc Tangent
Arc Tangent of an angle is the angle whose tangent is the given value.
atan(value);
atan(0); // returns 0
atan(1); // returns PI/4
atan(-1); // returns -PI/4
2 Argument Arc Tangent
atan2(y,x) is defined as the angle between the positive x-axis and the ray to the point(x,y).
atan2(y,x);
atan2(0,1); // returns 0
atan2(1,1); // returns PI/4
atan2(-1,1); // returns -PI/4
Coming up are the Hyperbolic Functions
Hyperbolic functions are analogues of the ordinary trigonometric functions, but defined using the hyperbola rather than the circle.
Hyperbolic Sine
Hyperbolic sine of an angle is the length of the line joining the x-axis and the point on the hyperbola at the same angle.
It can also be defined in form of exponents.
$$\sinh(\theta)=\frac{e^x-e^{-x}}{2}$$
sinh(angle);
sinh(0); // returns 0
sinh(PI/2); // returns 2.3012989023072947
sinh(PI); // returns 11.548739357257748
Graphical representation of the all Hyperbolic function:
Hyperbolic Cosine
Hyperbolic cosine of an angle is the length of the line joining the y-axis and the point on the hyperbola at the same angle.
It can also be defined in form of exponents.
$$\cosh(\theta)=\frac{e^x+e^{-x}}{2}$$
cosh(angle);
cosh(0); // returns 1
cosh(PI/2); // returns 2.5091784786580567
cosh(PI); // returns 11.591953275521519
Hyperbolic Tangent
Hyperbolic tangent of an angle is the slope of the line joining the origin and the point on the hyperbola at the same angle.
It can also be defined in form of exponents.
$$\tanh(\theta)=\frac{e^x-e^{-x}}{e^x+e^{-x}}$$
tanh(angle);
tanh(0); // returns 0
tanh(PI/2); // returns 0.9171523356672744
tanh(PI); // returns 0.99627207622075