1 package JSci.tests; 2 3 import JSci.maths.Quaternion; 4 5 9 public class QuaternionTest extends junitx.extensions.EqualsHashCodeTestCase { 10 private double w, x, y, z; 11 private double s, t, u, v; 12 13 public static void main(String arg[]) { 14 junit.textui.TestRunner.run(QuaternionTest.class); 15 } 16 public QuaternionTest(String name) { 17 super(name); 18 } 19 protected void setUp() throws Exception { 20 JSci.GlobalSettings.ZERO_TOL=1.0e-10; 21 w = Math.random(); 22 x = Math.random(); 23 y = Math.random(); 24 z = Math.random(); 25 s = Math.random(); 26 t = Math.random(); 27 u = Math.random(); 28 v = Math.random(); 29 super.setUp(); 30 } 31 protected Object createInstance() { 32 return new Quaternion(w, x, y, z); 33 } 34 protected Object createNotEqualInstance() { 35 return new Quaternion(s, t, u, v); 36 } 37 public void testExp() { 38 Quaternion expected = (Quaternion) createInstance(); 39 Quaternion actual=Quaternion.exp(Quaternion.log(expected)); 40 assertEquals(expected, actual); 41 } 42 public void testRotationMatrixConversion() { 43 Quaternion expected = (Quaternion) createInstance(); 44 expected = expected.divide(expected.norm()); 46 Quaternion actual = Quaternion.rotation(expected.toRotationMatrix()); 47 assertEquals(expected, actual); 48 } 49 } 50 51 | Popular Tags |