Radians

Started by
3 comments, last by dta1 21 years, 11 months ago
Can someone explain what Radians is and hw to use them.
Erase, rewind and improve
Advertisement
A radian is a measure of a portion of a circle. They basically work similarly to degrees. There are 360 degrees in a circle, as you know. There are also 2*pi radians in a circle. So 2*pi = 360 degrees. The reasoning behind this is that in a circle with radius 1, the circumference is 2*pi (2*pi*r = 2*pi*1 = 2*pi).

To convert degrees to radians, multiply by pi/180 (2*pi/360 degrees). To convert back to degrees, use 180/pi.

IIRC, stuff like glRotatef() is in degrees, but the trig functions (sin, cos, tan) in math.h are in radians. You will have to convert to radians when you want to use one of these functions, or if you use radians in the rest of your program, you will have to convert to degrees when you want to use an OGL function.
If have a dot at (0,0) and another at (5,5). And I want to draw a line between them. How do I use the sin,cos or tan with radians to do that?

What I intend do make is a thing which always looks towards a moving dot on the screen. Everything in 2D.
Erase, rewind and improve
simple trig.

0 -> 5 = adj
0 -> 5 = op

bang it into the correct forumla to get teh angle in degrees
convert it like DC_Tsunami said
there ya have ya angle in radians ready to use

not gonna tell ya HOW to do it code wise however, that is an exercise left to the reader

You don''t need an angle (radians or degrees) to do that.
IMBW, but it sounds like you want the unit-vector pointing from Origin to (x,y).

You can compute it this way:

x=5
y=5
r=sqrt(x*x+y*y)
unit_x = x/r
unit_y = y/r

But its still a good idea to brush up on radians, they have some neat properties. Eg, when you use radians, the following approximations hold for "sufficiently small phi":

sin phi = phi*phi/2
cos phi = 1 - phi

"Sufficiently small" depends on the application. Its too small in your case, but you can add higher-order terms to get better precision. Search google for Taylor Expansion.

---------
"It''''s always useful when you face an enemy prepared to die for his country. That means both of you have exactly the same aim in mind." -Terry Pratchett
---------"It''s always useful when you face an enemy prepared to die for his country. That means both of you have exactly the same aim in mind." -Terry Pratchett

This topic is closed to new replies.

Advertisement