• Advertisement
Sign in to follow this  

converting Radians to a custom degrees system

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

Ok heres the thing

my engine uses radians for any type of rotation but I want my players to get rotation info on a more simple way


If I were to just convert rads to degrees I would get this:

(imagine circles)

[SOURCE]

270

180 0/360

90


but what I want is this:


90

0 0

-90

[/SOURCE]

so this way the user know that when he changes its facing (left or right) his angle changes too

supposing the shooting angle of the player is 0 but the player is on a 45º slope


his real shooting angle then would be

facing left

\__ <- this is 45º

then facing right the same angle becomes

--\ <- this is -45º

hope Im making any sense here :)

Share this post


Link to post
Share on other sites
Advertisement
Why do you think that is simpler? It's simpler what works as expected. If I have to set an angle then I expect to set it using radians or degrees. If you prefer to work with positive and negative angles you can use the interval (-180°, 180°] instead of the usual [0, 360°), but the two zeros are not intuitive in my opinion. I can't say for example what are the correct values for the angles in the various quadrants.

Share this post


Link to post
Share on other sites
its intuitive because the player will no be able to shoot backwards usually angles are limited up to 50º

you can reach higher angles by positioning yourself on high slopes

Share this post


Link to post
Share on other sites
double map_standard_degrees_to_EvilNando_degrees(double x) {
return x < 90.0 ? x
: x < 270.0 ? 180.0 - x
: x - 360.0;
}



Edit: Actually, I didn't read your "normal degrees" diagram. Usually 90 is up. Anyway, programming a piece-wise linear function is trivial. Try it.

Share this post


Link to post
Share on other sites
lol I was doing that same thing on paper but I thought maybe there was some clever formula out there to help me out hehe

Share this post


Link to post
Share on other sites
Check out the Sine function:
It is zero at 0, Pi, and 2Pi.
It is +1 at Pi/2
It is -1 at 3Pi/2

Your formula would look something like this:
Custom Angle = 90 * Sin(theta);

where theta is your angle (in radians).

Oh, and your first circle is drawn upside down. 270 is on the bottom and 90 is on the top.

Share this post


Link to post
Share on other sites
How do you distinguish up-and-to-the-left from up-and-to-the-right, for example?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement