X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=test%2Fnet%2Fsf%2Fopenrocket%2Futil%2FRotation2DTest.java;fp=test%2Fnet%2Fsf%2Fopenrocket%2Futil%2FRotation2DTest.java;h=6cc6d91f2052df8614a8e3a0ecdf4a5de069718b;hb=dfc10c016c5f1bb4b7714dff414562f2f32e2866;hp=0000000000000000000000000000000000000000;hpb=84086eec3f20c7af0c4817548de4e8296c7674f8;p=debian%2Fopenrocket diff --git a/test/net/sf/openrocket/util/Rotation2DTest.java b/test/net/sf/openrocket/util/Rotation2DTest.java new file mode 100644 index 00000000..6cc6d91f --- /dev/null +++ b/test/net/sf/openrocket/util/Rotation2DTest.java @@ -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)); + + } + +}