# how many radians in 360deg?

This topic is 4864 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I am generating a lookup table for rotation, and i need to loop through all 360 degrees, but i need to do this in radians, so how many radians == 360 degrees? Thanks

##### Share on other sites

360 * (angle / (2Pi))

2Pi * (angle / 360)

Illco

##### Share on other sites
lol

i knew it wouldnt be just a simple number :)

so something along the lines of 2(3.14) or 6.28?

##### Share on other sites
Nothing is simple ;-)

I assume the look-up table contains some trigonometric values in dependence of the angle? If so, then there is no real need to not have 360 values in the table, e.g. this way:
table[angle_in_deg] = sin(angle_in_deg/(2*PI));

Say: It's the question for _what_ you need radians: For the index or else for the value at the index (however, also in the former case you could do a radian to degree conversion before indexing, of course).

(BTW: You may also take into account that sin(x) = cos(0.5*PI-x), and that sine and cosine are periodic, so that w/ a little bit of case distinction a look-up for 90 degrees could be sufficient.)

EDIT: Bug in sin - cos relation correct; thx to deavik's hint below.

[Edited by - haegarr on November 30, 2005 4:29:15 AM]

##### Share on other sites
ok, i see. by using a lookup table i dont really need radians, just the formula for init my table, which you have provided.

Thanks :)

##### Share on other sites
If you are going to use trig tables, do yourself a favor and use 256 "degrees" in a circle (or some other power of 2) instead of 360. This allows for very simple and extremely efficient wrapping of angles using a bitwise and operation.

- Rockoon (Joseph Koss)

##### Share on other sites
Slightly O/T but, do a google search for "how many radians in X degrees", where X is the number of degrees you are looking for, and it will calculate it for you. Google Calculator is definitly one of those resources you should keep handy! Just throwing that out for anyone who has not seen that cool functionality [wink]. You can even do things such as "6.28318531 radians / pi".

##### Share on other sites
Quote:
 Original post by haegarr(BTW: You may also take into account that sin(x) = cos(x-0.5*PI) ...

Just to save SelethD any confusion he may later have--you should remember that as sin(x) = cos(π/2 - x), and not the other way round. Since cos(-x) = cos(x), it does not make any difference in this case; but it will if you try to use the related relation cos(x) = sin(π/2 - x) in the form cos(x) = sin(x - π/2)--you will get an incorrect result.

Please note haegarr, I'm not trying to nitpick [smile]--the rest of the post was very good, including the idea for 90 degree lookups. As a matter of fact--because you can use the above mentioned relation, a 45 degree lookup will do.

##### Share on other sites
Quote:
 Original post by deavikremember that as sin(x) = cos(π/2 - x), and not the other way round.

Thx for the hint. Have corrected the arg's sign in my post above.

Quote:
 Original post by deavikPlease note haegarr, I'm not trying to nitpick [smile]--the rest of the post was very good, including the idea for 90 degree lookups. As a matter of fact--because you can use the above mentioned relation, a 45 degree lookup will do.

Hmm? The reduction formulas of sin and cos functions are for angles between 90 and 360 degrees. At 90 degrees the sine curve has reached the first maximum. How should this be reduced to 45 degrees (pi/2 is 90 degrees). Am I missing something?

##### Share on other sites
Quote:
 Original post by haegarrHmm? The reduction formulas of sin and cos functions are for angles between 90 and 360 degrees. At 90 degrees the sine curve has reached the first maximum. How should this be reduced to 45 degrees (pi/2 is 90 degrees). Am I missing something?

After I re-read my post, I think you misunderstood that a little. It will be enough to have values corresponding to the range 0->45 degrees for both sin(x) and cos(x). If you want to keep just the values of sin(x) in your table, then you will need values for 0->90 degrees.

Boils down to the same thing, though ... because sin (x) = cos (90 - x).

/edit: Theoretically, it's possible to drive a lookup using just the values of sin(0) through sin(45) and using the relation cos2(x) = 1 - sin2(x) to get the values of cos 0 to cos 45. After that use the complementary angle relation and get values of sin and cos for all x 0->90. From there, it's simple. But this approach requires more computing power, using a square and a square root, and the little more memory for the lookup table (0->90) is more practical.

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 14
• 12
• 29
• 11
• 44
• ### Forum Statistics

• Total Topics
634856
• Total Posts
3019661
×