good way to clamp angle
If you always want your angle between -PI and +PI (or any other full circle of rotation), what is the best way to do it? For example, and angle of 2*PI is too big and is equivalent to 0, so replace it with 0. Right now I''m using a loop that subtracts or adds 2*PI until the angle is valid. If you had to do this many many times, it is kind of inefficient. Any way with the modulus operation if you''re using floats?
Thx!
You can use the repeated substraction without huge huge waste of time like this:
Edited by - Diodor on April 4, 2001 1:06:30 PM
Sorry bout the buggy code. Hope this one does it.
Edited by - Diodor on April 5, 2001 6:09:41 PM
|
Edited by - Diodor on April 4, 2001 1:06:30 PM
Sorry bout the buggy code. Hope this one does it.
Edited by - Diodor on April 5, 2001 6:09:41 PM
Thx, the floor/ceiling way works, with some minor adjustments. (your code moves in PI increments, and in radians angle != angle + PI) Didn''t try the fmod thing but it looks like it would work too.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement