Radian Angles

When working with trigonometric functions in JavaScript the units have to be in radians and not in degrees. Radians are a standard unit of angular measurement. A radian is the angle that is swept out when the radius of a circle and the swept out arc length are equal in length.

clip_image002

Figure 1 One Radian

A complete circle, 360º, is equivalent to 2π radians. Thus the conversion from degrees to radians is as follows:

clip_image004

The conversion from radians to degrees is as follows:

clip_image006

Application

The conversion between degrees and radians will be used often. Knowing this we will create two functions that will convert from degrees to radians and back again.

function DegtoRad(x){
 return x*Math.PI/180;
}

function RadtoDeg(x){
 return x*180/Math.PI;
}

Listing 1 Conversion function for radians and degrees

Advertisements

One thought on “Radian Angles

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s