Package jinngine.math

Examples of jinngine.math.Matrix4


        new Matrix4().multiply((Matrix4) null);
    }

    @Test
    public void testAssignMultiply01() {
        final Matrix4 m = new Matrix4(
                1., 2., 3., 4.,
                5., 6., 7., 8.,
                9., 10, 11, 12,
                13, 14, 15, 16);
        final Matrix4 n = new Matrix4(
                10., 20., 30., 40.,
                50., 60., 70., 80.,
                90., 100, 110, 120,
                130, 140, 150, 160);
        final Matrix4 r = m.assignMultiply(n);
        assertSame(m, r); // r is m
        assertNotSame(n, r); // R is new       
        //Input is not changed
        assertMatrixEquals(new double[]{
                    10., 20., 30., 40.,
View Full Code Here


                    4260.0, 4840.0, 5420.0, 6000.0,}, r);
    }

    @Test(expected = NullPointerException.class)
    public void testAssignMultiply02() {
        new Matrix4().assignMultiply((Matrix4) null);
    }
View Full Code Here

        new Matrix4().assignMultiply((Matrix4) null);
    }

    @Test
    public void testMultiplyVector01() {
        final Matrix4 m = new Matrix4(
                1., 2., 3., 4.,
                5., 6., 7., 8.,
                9., 10, 11, 12,
                13, 14, 15, 16);
        final Vector3 v = new Vector3(100., 10000., 1000000.);
        final Vector3 r = m.multiply(v);
        assertNotSame(r, v);//new Vector3 is returned
        //Input is not changed
        assertMatrixEquals(new double[]{
                    1., 2., 3., 4.,
                    5., 6., 7., 8.,
View Full Code Here

    }

    @Test(expected = NullPointerException.class)
    public void testAssignMultiplyVector02() {
        new Matrix4().multiply((Vector3) null);
    }
View Full Code Here

        new Matrix4().multiply((Vector3) null);
    }

    @Test
    public void testIsNan() {
        final Matrix4 m = new Matrix4(
                1., 2., 3., 4.,
                5., 6., 7., 8.,
                9., 10, 11, 12,
                13, 14, 15, 16);
        assertFalse(m.isNaN());
        assertMatrixEquals(new double[]{
                    1., 2., 3., 4.,
                    5., 6., 7., 8.,
                    9., 10, 11, 12,
                    13, 14, 15, 16}, m);

        assertTrue(new Matrix4(
                1., Double.NaN, 3., 4.,
                5., 6., 7., 8.,
                9., 10, 11, 12,
                13, 14, 15, 16).isNaN());
        assertTrue(new Matrix4(
                1., 2., Double.NaN, 4.,
                5., 6., 7., 8.,
                9., 10, 11, 12,
                13, 14, 15, 16).isNaN());
        assertTrue(new Matrix4(
                1., 2., 3., Double.NaN,
                5., 6., 7., 8.,
                9., 10, 11, 12,
                13, 14, 15, 16).isNaN());
        assertTrue(new Matrix4(
                1., 2., 3., 4.,
                Double.NaN, 6., 7., 8.,
                9., 10, 11, 12,
                13, 14, 15, 16).isNaN());
        assertTrue(new Matrix4(
                1., 2., 3., 4.,
                5., Double.NaN, 7., 8.,
                9., 10, 11, 12,
                13, 14, 15, 16).isNaN());
        assertTrue(new Matrix4(
                1., 2., 3., 4.,
                5., 6., Double.NaN, 8.,
                9., 10, 11, 12,
                13, 14, 15, 16).isNaN());
        assertTrue(new Matrix4(
                1., 2., 3., 4.,
                5., 6., 7., Double.NaN,
                9., 10, 11, 12,
                13, 14, 15, 16).isNaN());
        assertTrue(new Matrix4(
                1., 2., 3., 4.,
                5., 6., 7., 8.,
                Double.NaN, 10, 11, 12,
                13, 14, 15, 16).isNaN());
        assertTrue(new Matrix4(
                1., 2., 3., 4.,
                5., 6., 7., 8.,
                9., Double.NaN, 11, 12,
                13, 14, 15, 16).isNaN());
        assertTrue(new Matrix4(
                1., 2., 3., 4.,
                5., 6., 7., 8.,
                9., 10, Double.NaN, 12,
                13, 14, 15, 16).isNaN());
        assertTrue(new Matrix4(
                1., 2., 3., 4.,
                5., 6., 7., 8.,
                9., 10, 11, Double.NaN,
                13, 14, 15, 16).isNaN());
        assertTrue(new Matrix4(
                1., 2., 3., 4.,
                5., 6., 7., 8.,
                9., 10, 11, 12,
                Double.NaN, 14, 15, 16).isNaN());

        assertTrue(new Matrix4(
                1., 2., 3., 4.,
                5., 6., 7., 8.,
                9., 10, 11, 12,
                13, Double.NaN, 15, 16).isNaN());
        assertTrue(new Matrix4(
                1., 2., 3., 4.,
                5., 6., 7., 8.,
                9., 10, 11, 12,
                13, 14, Double.NaN, 16).isNaN());
        assertTrue(new Matrix4(
                1., 2., 3., 4.,
                5., 6., 7., 8.,
                9., 10, 11, 12,
                13, 14, 15, Double.NaN).isNaN());
View Full Code Here

    }

    @Test
    public void testInverse01() {
        Matrix4 m = Matrix4.scaleMatrix(2, 3, 4);
        Matrix4 r = m.inverse();
        assertNotSame(r, m);
        assertMatrixEquals(new double[]{
                    2.0, 0.0, 0.0, 0.0,
                    0.0, 3.0, 0.0, 0.0,
                    0.0, 0.0, 4.0, 0.0,
                    0.0, 0.0, 0.0, 1.0}, m);
        Matrix4 i = r.assignMultiply(m);
        assertMatrixEquals(new double[]{
                    1., 0., 0., 0.,
                    0., 1., 0., 0.,
                    0., 0., 1., 0.,
                    0., 0., 0., 1.}, i, 1E-15);
View Full Code Here

                    0., 0., 0., 1.}, i, 1E-15);
    }

    @Test
    public void testInverse02() {
        Matrix4 m = new Matrix4(
                1., 0., 0., 0.,
                0., 1., 0., 0.,
                0., 0., 1., 0.,
                0., 0., 0., 1.);
        Matrix4 r = m.inverse();
        assertMatrixEquals(new double[]{
                    1., 0., 0., 0.,
                    0., 1., 0., 0.,
                    0., 0., 1., 0.,
                    0., 0., 0., 1.}, r, 1E-15);
View Full Code Here

    }

    @Test
    public void testToArray() {

        final Matrix4 m = new Matrix4(
                1., 2., 3., 4.,
                5., 6., 7., 8.,
                9., 10, 11, 12,
                13, 14, 15, 16);
        final double[] d = m.toArray();
        final double[] d2 = m.toArray();
        assertNotSame(
                d, d2);
        assertMatrixEquals(
                new double[]{
                    1., 2., 3., 4.,
View Full Code Here

    @Test
    public void testToString() {
        assertEquals("[1.0, 2.0, 3.0, 4.0]\n"
                + "[5.0, 6.0, 7.0, 8.0]\n"
                + "[9.0, 10.0, 11.0, 12.0]\n"
                + "[13.0, 14.0, 15.0, 16.0]", new Matrix4(
                1., 2., 3., 4.,
                5., 6., 7., 8.,
                9., 10, 11, 12,
                13, 14, 15, 16).toString());
    }
View Full Code Here

        assertMatrixEquals(ref, val, 0.);
    }

    @Test
    public void testCtorZero() {
        final Matrix4 m = new Matrix4();
        assertMatrixEquals(new double[]{
                    0., 0., 0., 0.,
                    0., 0., 0., 0.,
                    0., 0., 0., 0.,
                    0., 0., 0., 0.,}, m);
View Full Code Here

TOP

Related Classes of jinngine.math.Matrix4

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.