Source: Internet
Author: User

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

Radians and degrees are two different units of the measurement angle. Just like "meters" and "city ruler" are two different units that measure the length.

In flash, the angle in rotation is measured in degrees, and the angle in trigonometric functions is measured in radians. This rule must be remembered first !!! For example, rotation2 -- is the rotation "2 degrees"; sin (π/2) -- is the sine of the angle of the "π/2 radian.

Ii. radians

The so-called "radian definition" is to say, how is the angle size of 1 radian defined?

We know that "degree" is defined as "two rays are emitted from the center of the circle to the circumference to form an arc with a positive angle and angle. When the arc length is equal to 360 of the circumference, the angle between the two rays is 1 degree. (1)

How is radian defined? Radians are defined as follows: two rays are emitted from the center of the circle to the circumference, forming an arc with a positive angle and an angle. When the arc length is equal to the circle radius, the angle between the two rays is 1 radian. (2)

By comparison, the two definitions of degrees and radians are very similar. They differ only in the ARC lengths of different angles. Degrees are equal to one of the 360 points of the circumference, while radians are equal to the radius.

To put it simply, radians define that when the arc lengths of an angle are equal to the radius, the angle size is 1 radian.

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

For example:

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 °/π

For example:

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.

Related Article