The math function of as getting started--radians

Source: Internet
Author: User
Tags convert radians to degrees expression
Function

Before we learn trigonometric functions, we first understand a concept-- radians .

In daily life we use the metric angle of the unit is the degree. A circumference is 360 degrees, but this number is arbitrary. The Radian units are the standard metric units of the measuring angles defined by mathematicians. Radians are defined based on PI, which is an intrinsic property of a circle. The computer programming language is usually in radians when processing an angle. The built-in math class for Flash as, which is calculated in radians.

The radian is defined as follows: Two rays are projected from the center of the circle to the circumference, forming an arc with an angle and a positive pair of angles. When the arc length is exactly equal to the radius of the circle, the angle of the two rays is 1 radians. Let's take a look at the following illustration:

In this figure, the radian of the angle θ can be computed using this formula: The arc length is s and the radius is L, then the radian value of the angle θ is θ=s/l.

Pi is a constant, in the flash as, with Math.PI to define, pi value is 3.1415 .... We can test:

P=math.pi
Trace (p)//output is: 3.14159265358979

So. How do you convert degrees to radians? The basic relationship is that pi radians equals 180 degrees to π:180. So 2π radians equals 360 degrees, which is a circle. The formula for the conversion is:

radians = degrees xπ/180

In Flash as, we can use this function to convert:

function Dzhd (Angel) {//angel for a degree representation of the angle, custom one of the functions Dzhd

Return angel* (math.pi/180)

}

We can test this function:

function Dzhd (Angel) {
Return angel* (math.pi/180)
}
X=dzhd (180)
Trace (x)//output is 3.14159265358979, which is pi

Of course, we do not have to use the process of using a function to convert, we can directly use an expression to convert, is also possible. For example, to convert an angle angel to a radian Hudu value, you can use the following to indicate

hudu=angel* (MATH.PI)/180

Test:

angel=180
hudu=angel* (math.pi/180)
Trace (Hudu)//output is 3.14159265358979, which is pi

Similarly, we can also convert radians to degrees. Radian value multiplied by 180/π get angle:

Custom functions:

function Hdzd (Hudu) {

Return hudu* (180/MATH.PI)

}

Test:

function Hdzd (Hudu) {
Return hudu* (180/MATH.PI)
}
X=HDZD (1)
Trace (x)//output is 57.2957795130823, actually 1 radians corresponds to 57.3 degrees.

In the same way, we can also use an expression directly instead of a function. angel=hudu* (180/MATH.PI)

Test:

Hudu=1
angel=hudu* (180/MATH.PI)
Trace (Angel)//Also output is 57.2957795130823, actually 1 radians corresponds to 57.3 degrees.



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.