updates for 0.9.3
[debian/openrocket] / test / net / sf / openrocket / util / Rotation2DTest.java
diff --git a/test/net/sf/openrocket/util/Rotation2DTest.java b/test/net/sf/openrocket/util/Rotation2DTest.java
new file mode 100644 (file)
index 0000000..6cc6d91
--- /dev/null
@@ -0,0 +1,31 @@
+package net.sf.openrocket.util;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+
+public class Rotation2DTest {
+       
+       @Test
+       public void rotationTest() {
+               
+               double rot60 = 0.5;
+               double rot30 = Math.sqrt(3)/2;
+               
+               Coordinate x = new Coordinate(1,1,0);
+               Coordinate y = new Coordinate(0,1,1);
+               
+               Rotation2D rot = new Rotation2D(Math.PI/3);  // 60 deg
+               
+               assertEquals(new Coordinate(rot60, 1, -rot30), rot.rotateY(x));
+               assertEquals(new Coordinate(rot60, 1, rot30), rot.invRotateY(x));
+               
+               assertEquals(new Coordinate(1, rot60, rot30), rot.rotateX(x));
+               assertEquals(new Coordinate(1, rot60, -rot30), rot.invRotateX(x));
+               
+               assertEquals(new Coordinate(-rot30, rot60, 1), rot.rotateZ(y));
+               assertEquals(new Coordinate(rot30, rot60, 1), rot.invRotateZ(y));
+               
+       }
+
+}