Make the upper bound exclusive in normalizeAngle(Positive).
This commit is contained in:
@@ -138,26 +138,26 @@ public class MathUtil
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an angle in the range [-pi, pi].
|
* Returns an angle in the range [-pi, pi).
|
||||||
*/
|
*/
|
||||||
public static double normalizeAngle (double a) {
|
public static double normalizeAngle (double a) {
|
||||||
while (a < -Math.PI) {
|
while (a < -Math.PI) {
|
||||||
a += TWO_PI;
|
a += TWO_PI;
|
||||||
}
|
}
|
||||||
while (a > Math.PI) {
|
while (a >= Math.PI) {
|
||||||
a -= TWO_PI;
|
a -= TWO_PI;
|
||||||
}
|
}
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an angle in the range [0, 2pi].
|
* Returns an angle in the range [0, 2pi).
|
||||||
*/
|
*/
|
||||||
public static double normalizeAnglePositive (double a) {
|
public static double normalizeAnglePositive (double a) {
|
||||||
while (a < 0f) {
|
while (a < 0f) {
|
||||||
a += TWO_PI;
|
a += TWO_PI;
|
||||||
}
|
}
|
||||||
while (a > TWO_PI) {
|
while (a >= TWO_PI) {
|
||||||
a -= TWO_PI;
|
a -= TWO_PI;
|
||||||
}
|
}
|
||||||
return a;
|
return a;
|
||||||
|
|||||||
@@ -138,26 +138,26 @@ public class MathUtil
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an angle in the range [-pi, pi].
|
* Returns an angle in the range [-pi, pi).
|
||||||
*/
|
*/
|
||||||
public static float normalizeAngle (float a) {
|
public static float normalizeAngle (float a) {
|
||||||
while (a < -FloatMath.PI) {
|
while (a < -FloatMath.PI) {
|
||||||
a += TWO_PI;
|
a += TWO_PI;
|
||||||
}
|
}
|
||||||
while (a > FloatMath.PI) {
|
while (a >= FloatMath.PI) {
|
||||||
a -= TWO_PI;
|
a -= TWO_PI;
|
||||||
}
|
}
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an angle in the range [0, 2pi].
|
* Returns an angle in the range [0, 2pi).
|
||||||
*/
|
*/
|
||||||
public static float normalizeAnglePositive (float a) {
|
public static float normalizeAnglePositive (float a) {
|
||||||
while (a < 0f) {
|
while (a < 0f) {
|
||||||
a += TWO_PI;
|
a += TWO_PI;
|
||||||
}
|
}
|
||||||
while (a > TWO_PI) {
|
while (a >= TWO_PI) {
|
||||||
a -= TWO_PI;
|
a -= TWO_PI;
|
||||||
}
|
}
|
||||||
return a;
|
return a;
|
||||||
|
|||||||
Reference in New Issue
Block a user