To rotate any angle to the range 0-359 in C # you can use the following "algorithm":
public int Normalise (int degrees) {
int retval = degrees % 360;
if (retval < 0)
retval += 360;
return retval;
}
C # follows the same rules as C and C ++, and i % 360provides you with a value between -359and 359for any integer, then the second line should provide it in the range from 0 to 359 inclusive.
:
degrees = ((degrees % 360) + 360) % 360;
. , , , .
degrees % 360 -359 359. 360 1 729. % 360 0 359.