In the past two days, I have read the quad-tree code written by my colleagues. The conversion between degrees and degrees is used, so I reprinted this article and learned it.
01 radian relationship with angle 1. Two angle units
The image of this topic is as follows:
The arc length of an angle is several times the radius, and the angle size is several radians.
Their relationships can be expressed and calculated in the following formula:
Angle (radian) = arc length/radius
The circumference of a circle is 2 π times the radius, so a circumference (360 degrees) is 2 π radians.
The length of the semi-circle is π times the radius, so an angle (180 degrees) is π radian.
Iii. Conversion between degrees and radians
According to the above, an angle is π radian.
That is, 180 degrees = π radians
We can see that:
1 degree = π/180 radian (≈ 0.017453 radian)
Therefore, the formula for converting degrees into radians is obtained:
Radians = degrees x π/180
90 ° = 90 × π/180 = π/2 radian
60 ° = 60 × π/180 = π/3 radian
45 ° = 45 × π/180 = π/4 radian
30 ° = 30 × π/180 = π/6 radian
120 ° = 120xπ/180 = 2 π/3 radian
In turn, how is the radians converted into degrees?
Because π radian = 180 °
So 1 radian = 180 °/π (≈ 57.3 °)
Therefore, we can get a formula to convert radians into degrees:
Degrees = radians × 180 °/π
4 π/3 radian = 4 π/3 × 180 °/π
= 240 °
Some may say that it is easy to make a mistake if it is multiplied by "π/180" or "180 °/π. In fact, you only need to remember that π is π radians, and 180 is 180 degrees. If I want to become a unit, I need to put it on the numerator. That is to say, to convert it into a radian, we need to put the π radian on the numerator -- multiply by π/180. In addition, 1 is much smaller than 1 radian, and only about 0.017453 radian (π/180 ≈ 0.017453 ). So after degrees are converted into radians, the number must be smaller, so the radians must be multiplied by π/180. If you think about it like this, you won't be mistaken.
In the as code, "π" is written as "Pi ". Because "π" and "sin" are all "mathematical functions", we should add "math" to the front according to the regulations. "(math is the abbreviation of" Mathematics "in English. pi "," math. sin ".
Therefore, sin30° must be written as math. Sin (30 * Math. PI/180 ). The section in the small arc converts 30 ° into a radian, that is, 30 × π/180.