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

## Recommended Posts

This thread is technically a maths subject, but its purpose relates more to code consistency so I thought I'd throw it in here.

Following on from this "retired" thread, I've found that adding 90.0f to any number in radians that has been converted to degrees will give me that number in this range of degrees:

I'm not sure why I prefer that ^ way of looking at degrees, but I've grown up with it and would like to stick to it as it's easier to visualise.

I figure I'll change my rad/deg conversion functions to look like this:
float Maths::rad_to_deg(float radians){	return (radians * (180.0f / PI)) + 90.0f;}float Maths::deg_to_rad(float degrees){	return (degrees - 90.0f) * (PI / 180.0f);}

Providing that I use these conversion functions for every radians<->degrees conversion in my code, are there any issues with handling conversions this way?

Cheers.

##### Share on other sites
It will all work fine, but you'd be better off:
(1) Following the conventions that everyone else uses (0 is where x goes up, 90 where y goes up).
(3) Not using angles at all if it can be avoided.

##### Share on other sites
I'm just going to echo alvaro: forget about 0-up, get used to the standard convention, and drop the conversions. It'll make things much easier in the long run.

##### Share on other sites
First of all, that 'conversion' won't work. Adding 90 to the range 0-360 makes the range 90 - 450 degrees. You need a wrap function to do that properly. Plus, if you want clockwise rotation (as shown in your image) rather than counterclockwise, you need to change the sign. 360 - (180/pi) would get the result in your image, save for starting at the y axis. To get that, add another 90, and subtract 360 if result>360, i.e.
d = 450 - r(180/pi);if (d>=360) d -= 360;

But I STRONGLY recommend dropping this scheme entirely, as others here have said. What possible good does this do you? Even "normal" degrees are pretty much useless pro grammatically. Do you just want this value to display to a user by chance?

##### Share on other sites
Thanks for the input guys. :)

No it's not to display to a user, it was just to aid me when debugging, etc. as I have trouble reading degrees the way they're meant to be. Plus I have a bunch of artwork that relies on the convention I'm currently using.

1. 1
2. 2
3. 3
frob
20
4. 4
Rutin
18
5. 5

• 33
• 13
• 10
• 9
• 18
• ### Forum Statistics

• Total Topics
632555
• Total Posts
3007062

×