Firstly, this may seem very trivial, but I'm currently creating a getQuadrant (degree) function to return a quadrant with a given angle.
For example, if degree> = 0 and <90, it will return 1. If degree> = 90 and <180, it will return 2. And so on. This is very trivial. However, to deal with degrees other than 0-360, I simply normalized these numbers in the range of 0-360 degrees, for example:
while (angle > 360) angle = angle - 360; end while (angle < 0) angle = angle + 360; end
After that I calculate. But honestly, I hate using such statements. Are there other mathematical methods that can point to the quadrant of an angle at a time?
EDIT: I see that there are many good answers. Let me add, " which algorithm will be the fastest? "
Karl
source share