#### Archived

This topic is now archived and is closed to further replies.

# Converting MSVC++ from radians to degrees

## Recommended Posts

Hey, It seems as though MSVC++ works in radians rather than degrees. I know i can get around it by using DegToRadian functions and stuff but i'll lose accuracy in my calculations that way. Is there any way to set MSVC++ to read it in degrees instead? 'Very funny, Scotty. Now beam down my clothes.' - Edited by - TheBlackJester on January 13, 2002 1:59:16 AM

##### Share on other sites
You post has nuked this thread (I''m not sure what''s wrong). However: When does MSVC ask for degrees or radians? The math libraries aren''t part of MSVC if that''s what you mean. Maybe there''s something I''ve missed in MSVC...

[Resist Windows XP''s Invasive Production Activation Technology!]

##### Share on other sites
Sorry about the nuke, it was my sig that i messed up.

Yeah, i guess your right about it being in the math files so theres really no way to change it

##### Share on other sites
Use a preprocessor macro (#define) to convert it for you at compile time so there is no loss in performance, and you gain the readability you want.

- Kevin "BaShildy" King
Game Programmer: DigiPen
www.mpogd.com

##### Share on other sites
Remember, there are 2*PI radians in a circle. So 360 degrees ~= 2 * PI radians. So to convert degrees to radians, just do this:

Hope this helps!

##### Share on other sites
Using radians is more accurate than degrees since they''re expressed with floats.

##### Share on other sites
Thnx,

Its true that they are expressed with floats, but if my angle is some number in degrees and I then convert that to radians, I lose data because of the non-exactness of conversion. In my case i need my camera to not be moving on the X axis if a given angle is 0, but since it was converted to radians its actually 0.010221 and is causing my cam to "float". This is un acceptable

''Very funny, Scotty. Now beam down my clothes.'' -

[TheBlackJester]

##### Share on other sites
Why not just use radians everywhere and not bother about conversions anywhere? Unless you have to have the user entering angles or reading angles, then I see no reason to use degrees.

Trying is the first step towards failure.

##### Share on other sites
There''s also no rule saying that you need an integer number of degrees! You can use floating points for radian angles AND degree angles.

##### Share on other sites
always use radians, never degrees. If you think you are having precision problems just use some sort of tolerance thing instead of the equality operator. If you switch back and forth you deserve the imprecision. Degrees have no value in math, science, or programming.

##### Share on other sites
Exactly. The formulas for all the trig functions are based on radians. If you want to use the trig functions, you should stay with radians.

I''ve seen some people who will read in an object''s position, calculate the angle from another point, convert that angle to degrees and store it. Later on, they read the angle, convert it back to radians (!!) and use it. I have to wonder what goes on inside their brains...

Alternatively, you can use lookup tables and your own angle units. Duke Nukem 3D, IIRC, had 2048 angle units in a circle.

##### Share on other sites
Also, you''re asking for trouble by testing a float against 0.0f. This:
if (f <= 0.01f)

is a better bet than this:

if (f == 0.0)

• ### Forum Statistics

• Total Topics
628381
• Total Posts
2982360

• 10
• 9
• 15
• 24
• 11