Exemple #1
0
 public static void testPositiveXRotateXY() {
   Vector3d dir = new Vector3d();
   Matrix4x3d m =
       new Matrix4x3d().rotateY((float) Math.toRadians(90)).rotateX((float) Math.toRadians(45));
   m.positiveX(dir);
   TestUtil.assertVector3dEquals(new Vector3d(0, 1, 1).normalize(), dir, 1E-7f);
 }
Exemple #2
0
 public static void testNormal() {
   Matrix4x3d r = new Matrix4x3d().rotateY((float) Math.PI / 2);
   Matrix4x3d s = new Matrix4x3d(r).scale(0.2f);
   Matrix4x3d n = new Matrix4x3d();
   s.normal(n);
   n.normalize3x3();
   TestUtil.assertMatrix4x3dEquals(r, n, 1E-8f);
 }
Exemple #3
0
 public static void testPositiveXYZLookAt() {
   Vector3d dir = new Vector3d();
   Matrix4x3d m = new Matrix4x3d().lookAt(0, 0, 0, -1, 0, 0, 0, 1, 0);
   m.positiveX(dir);
   TestUtil.assertVector3dEquals(new Vector3d(0, 0, -1).normalize(), dir, 1E-7f);
   m.positiveY(dir);
   TestUtil.assertVector3dEquals(new Vector3d(0, 1, 0).normalize(), dir, 1E-7f);
   m.positiveZ(dir);
   TestUtil.assertVector3dEquals(new Vector3d(1, 0, 0).normalize(), dir, 1E-7f);
 }
Exemple #4
0
 public static void testPositiveXYZSameAsInvert() {
   Vector3d dir = new Vector3d();
   Vector3d dir2 = new Vector3d();
   Matrix4x3d m = new Matrix4x3d().rotateXYZ(0.12f, 1.25f, -2.56f);
   Matrix4x3d inv = new Matrix4x3d(m).invert();
   m.positiveX(dir);
   inv.transformDirection(dir2.set(1, 0, 0));
   TestUtil.assertVector3dEquals(dir2, dir, 1E-6f);
   m.positiveY(dir);
   inv.transformDirection(dir2.set(0, 1, 0));
   TestUtil.assertVector3dEquals(dir2, dir, 1E-6f);
   m.positiveZ(dir);
   inv.transformDirection(dir2.set(0, 0, 1));
   TestUtil.assertVector3dEquals(dir2, dir, 1E-6f);
 }
Exemple #5
0
 public static void testInvert() {
   Matrix4x3d invm = new Matrix4x3d();
   Matrix4x3d m = new Matrix4x3d();
   m.rotateX(1.2f).rotateY(0.2f).rotateZ(0.1f).translate(1, 2, 3).invert(invm);
   Vector3d orig = new Vector3d(4, -6, 8);
   Vector3d v = new Vector3d();
   Vector3d w = new Vector3d();
   m.transformPosition(orig, v);
   invm.transformPosition(v, w);
   TestUtil.assertVector3dEquals(orig, w, 1E-6f);
   invm.invert();
   TestUtil.assertMatrix4x3dEquals(m, invm, 1E-6f);
 }
Exemple #6
0
 public static void testPositiveZRotateX() {
   Vector3d dir = new Vector3d();
   Matrix4x3d m = new Matrix4x3d().rotateX((float) Math.toRadians(90));
   m.positiveZ(dir);
   TestUtil.assertVector3dEquals(new Vector3d(0, 1, 0), dir, 1E-7f);
 }