Package toxi.geom

Examples of toxi.geom.Matrix4x4


        */
      //  p.addSelf(new Vec3D(myTransform.origin.x * scaleBy,
      //      (myTransform.origin.y * scaleBy),
      //    (myTransform.origin.z * scaleBy)));
      // g.rotateX((float) Math.PI);
      Matrix4x4 m = new Matrix4x4(myTransform.basis.m00,
          myTransform.basis.m01, myTransform.basis.m02, 0,
          myTransform.basis.m10, myTransform.basis.m11,
          myTransform.basis.m12, 0, myTransform.basis.m20,
          myTransform.basis.m21, myTransform.basis.m22, 0, 0, 0, 0, 1);

      p = m.applyTo(p);

      /*
      p = p.rotateX((float) Math.PI);
      p.subSelf(new Vec3D(center.x * scaleBy,
          (center.y * scaleBy), center.z
View Full Code Here


import toxi.math.MathUtils;

public class MatrixTest extends TestCase {

    public void testInverse() {
        Matrix4x4 m = new Matrix4x4();
        m.translateSelf(100, 100, 0);
        m.rotateX(MathUtils.HALF_PI);
        m.scaleSelf(10, 10, 10);
        System.out.println(m);
        Vec3D v = new Vec3D(0, 1, 0);
        Vec3D w = m.applyTo(v);
        m = m.getInverted();
        ReadonlyVec3D v2 = m.applyTo(w);
        System.out.println(w);
        System.out.println(v2);
        assertTrue(v2.equalsWithTolerance(v, 0.0001f));
    }
View Full Code Here

        System.out.println(v2);
        assertTrue(v2.equalsWithTolerance(v, 0.0001f));
    }

    public void testRotate() {
        Matrix4x4 m = new Matrix4x4();
        m.rotateX(MathUtils.HALF_PI);
        Vec3D v = m.applyTo(new Vec3D(0, 1, 0));
        assertTrue(new Vec3D(0, 0, 1).equalsWithTolerance(v, 0.00001f));
        m.identity();
        m.rotateY(MathUtils.HALF_PI);
        v = m.applyTo(new Vec3D(1, 0, 0));
        assertTrue(new Vec3D(0, 0, -1).equalsWithTolerance(v, 0.00001f));
        m.identity();
        m.rotateZ(MathUtils.HALF_PI);
        v = m.applyTo(new Vec3D(1, 0, 0));
        assertTrue(new Vec3D(0, 1, 0).equalsWithTolerance(v, 0.00001f));
        m.identity();
        m.rotateAroundAxis(new Vec3D(0, 1, 0), MathUtils.HALF_PI);
        v = m.applyTo(new Vec3D(1, 0, 0));
        assertTrue(new Vec3D(0, 0, 1).equalsWithTolerance(v, 0.00001f));
    }
View Full Code Here

        v = m.applyTo(new Vec3D(1, 0, 0));
        assertTrue(new Vec3D(0, 0, 1).equalsWithTolerance(v, 0.00001f));
    }

    public void testTranslate() {
        Matrix4x4 m = new Matrix4x4();
        m.translateSelf(100, 100, 100);
        assertEquals(new Vec3D(100, 100, 100), m.applyTo(new Vec3D()));
    }
View Full Code Here

        }
        return this;
    }

    public TriangleMesh flipYAxis() {
        transform(new Matrix4x4().scaleSelf(1, -1, 1));
        flipVertexOrder();
        return this;
    }
View Full Code Here

    public void testMatrixRoundtrip() {
        for (int i = 0; i < 1000; i++) {
            Quaternion q = Quaternion.createFromAxisAngle(Vec3D.randomVector(),
                    MathUtils.random(MathUtils.TWO_PI)).normalize();
            Matrix4x4 m = q.toMatrix4x4();
            Quaternion q2 = Quaternion.createFromMatrix(m);
            Vec3D p = Vec3D.randomVector();
            Vec3D p2 = p.copy();
            q.applyTo(p);
            q2.applyTo(p2);
View Full Code Here

TOP

Related Classes of toxi.geom.Matrix4x4

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.