Trigonometry mainly studies triangles and their corner relationships, which contain a 90-degree angle triangle called right triangle. Here the main research right triangle related knowledge.
1. Angles and radians
360 (angle) = 2*math.pi (radians)
degrees = radians * 180/math.pi angle equals radians multiplied by 180 again except for Piradians = degrees * math.pi/180 radians equals angle degree multiplied by PI and removed in 180
2. Edges of triangles
In a right triangle, the two edges adjacent to the 90-degree angle are called right-angled edges, and their corresponding edges are called hypotenuse, and the hypotenuse is always the longest edge.
3. Trigonometric Functions
sine : The ratio of the edge to the hypotenuse of a corner.
Sine of a 30-degree angle
Math.sin (* math.pi/180)
cosine : The ratio of the adjacent edge of a corner to the hypotenuse.
Cosine of a 30-degree angle
Math.Cos (* math.pi/180)
tangent : The ratio of the pair of edges to the adjacent edges of a corner.
Tangent of a 30-degree angle
Math.tan (* math.pi/180)
sine chord : math.asin (ratio)
inverse cosine : math.acos (ratio)
The inverse of the sine and cosine of the cosine is the inversion of the sinusoidal, and a ratio is entered to obtain a radian of the corresponding angle.
Math.sin (math.pi/180)//approx. 0.5 math.asin (0.5) * 180/math.pi//approx. 30 degrees
anyway cut : Math.atan (ratio)
Tangent angle is rounded by the ratio of the edge to the neighboring edge of a corner.
Math.tan (math.pi/180)//approx. 0.578 Math.atan (0.578) * 180/math.pi//approx. 30 degrees
JavaScript in another anyway tangent:math.atan2 (y,x)
The coordinate system in JavaScript is not the same as usual.
Calculates the angle of a point of change in a JavaScript coordinate system by using an inverse tangent (math.atan2) that corresponds to a fixed point:
Fixed point (arrow.x, ARROW.Y)
Change Point (mouse.x, MOUSE.Y)
var dx = mouse.x-arrow.x, dy = mouse.y-arrow.y, angle = math.atan2 (dy, dx); Console.log (' angle: ' + angle ');
In JavaScript calculations,math.atan2 (y, x) can correctly calculate the corresponding angle.
4. Pythagorean theorem
In right triangle, the square of two right-angled sides equals the square of the hypotenuse.
Squared of a squared + b = Square of C
Calculate the distance between two points
Point 1: (x1, y1)
Point 2: (x2, y2)
var dx = x2-x1, dy = y2-y1, dist = math.sqrt (dx * dx + dy * dy); Console.log (' Distance: ' + dist);
Trigonometry in JavaScript