HTML5 Canvas : Application Of Trigonometric Function
What is trigonometric function?
Trigonometric function is one of the basic elementary functions. It takes the angle (the most commonly used radian system in mathematics, the same below) as the independent variable. It can also be defined equivalently by the length of various line segments related to the unit circle.
In the application of HTML5 canvas, trigonometric function is generally used to calculate the unknown length edge and angle of triangle in canvas.
Common trigonometric functions include sine function, cosine function and tangent function. The javasript API provides math objects that contain these calculations.
//Returns the sine of a number.
Math.sin(x)
//Returns the cosine of a number.
Math.cos(x)
//Returns the tangent of a number.
Math.tan(x)
//Where parameter x is a value representing radians
//There are also some commonly used anti trigonometric functions
//Returns the arcsine of a number in radians.
Math.asin(x)
//Returns the arccosine of a number in radians.
Math.acos(x)
//Returns the arctangent of a number in radians.
Math.atan(x)
//Returns the value of the offset angle from the positive x axis to the line between the point (x, y) and the origin, which is a counterclockwise angle in radians.
Math.atan2(y, x)