mirrorAngle(HALF_PI) should be -HALFPI rather than HALF_PI

This commit is contained in:
Christoph Dietze
2013-02-12 22:10:04 +01:00
parent 6bdeeece12
commit 0ffabf1419
2 changed files with 20 additions and 1 deletions
+1 -1
View File
@@ -169,7 +169,7 @@ public class MathUtil
* Returns the mirror angle of the specified angle (assumed to be in [-pi, +pi]). * Returns the mirror angle of the specified angle (assumed to be in [-pi, +pi]).
*/ */
public static float mirrorAngle (float a) { public static float mirrorAngle (float a) {
return (a > 0f ? FloatMath.PI : -FloatMath.PI) - a; return a + (a > 0f ? -FloatMath.PI : FloatMath.PI);
} }
/** /**
@@ -0,0 +1,19 @@
//
// Pythagoras - a collection of geometry classes
// http://github.com/samskivert/pythagoras
package pythagoras.f;
import org.junit.*;
import static org.junit.Assert.*;
/**
* Tests parts of the {@link MathUtil} class.
*/
public class MathUtilTest
{
@Test public void testMirrorAngle() {
assertEquals(-MathUtil.HALF_PI, MathUtil.mirrorAngle(MathUtil.HALF_PI), MathUtil.EPSILON);
assertEquals(MathUtil.HALF_PI, MathUtil.mirrorAngle(-MathUtil.HALF_PI), MathUtil.EPSILON);
}
}