Exemplo n.º 1
0
        public float transform(float p)
        {
            LDVector3 srcVec = new LDVector3(p, 0, 0);
            LDVector3 dstVec = m_matrix.transform(srcVec);

            return(dstVec.x);
        }
Exemplo n.º 2
0
        public void transformTest()
        {
            LDVector3 vector=new LDVector3();
            LDVector3 expected = new LDVector3();
            LDVector3 actual = new LDVector3();
            LDMatrix44 matrix=new LDMatrix44();
            //ld_float delta = 0.00001f;

            // Input : matrix = 単位行列, vector = 0.0 (ゼロ)
            vector.zero();
            expected.x = 0.0f;
            expected.y = 0.0f;
            expected.z = 0.0f;
            actual = matrix.transform(vector);
            TestUtil.COMPARE(expected.x, actual.x);
            TestUtil.COMPARE(expected.y, actual.y);
            TestUtil.COMPARE(expected.z, actual.z);

            // Input : matrix = 任意の値, x = 1.0, y = 2.0, z = 3.0 (任意の値)
            vector.x = 1.0f;
            vector.y = 2.0f;
            vector.z = 3.0f;
            matrix.m11 = 1.0f;
            matrix.m12 = 2.0f;
            matrix.m13 = 3.0f;
            matrix.m14 = 4.0f;
            matrix.m21 = 1.0f;
            matrix.m22 = 2.0f;
            matrix.m23 = 3.0f;
            matrix.m24 = 4.0f;
            matrix.m31 = 1.0f;
            matrix.m32 = 2.0f;
            matrix.m33 = 3.0f;
            matrix.m34 = 4.0f;
            expected.x = matrix.m11 * vector.x + matrix.m12 * vector.y + matrix.m13 * vector.z + matrix.m14;
            expected.y = matrix.m21 * vector.x + matrix.m22 * vector.y + matrix.m13 * vector.z + matrix.m24;
            expected.z = matrix.m31 * vector.y + matrix.m32 * vector.y + matrix.m13 * vector.z + matrix.m34;
            actual = matrix.transform(vector);
            TestUtil.COMPARE(expected.x, actual.x);
            TestUtil.COMPARE(expected.y, actual.y);
            TestUtil.COMPARE(expected.z, actual.z);

            // Input : matrix = 任意の値, x = 1.0, y = 2.0, z = 3.0 (任意の値) (p == dstの場合)
            vector.x = 1.0f;
            vector.y = 2.0f;
            vector.z = 3.0f;
            matrix.m11 = 1.0f;
            matrix.m12 = 2.0f;
            matrix.m13 = 3.0f;
            matrix.m14 = 4.0f;
            matrix.m21 = 1.0f;
            matrix.m22 = 2.0f;
            matrix.m23 = 3.0f;
            matrix.m24 = 4.0f;
            matrix.m31 = 1.0f;
            matrix.m32 = 2.0f;
            matrix.m33 = 3.0f;
            matrix.m34 = 4.0f;
            expected.x = matrix.m11 * vector.x + matrix.m12 * vector.y + matrix.m13 * vector.z + matrix.m14;
            expected.y = matrix.m21 * vector.x + matrix.m22 * vector.y + matrix.m13 * vector.z + matrix.m24;
            expected.z = matrix.m31 * vector.y + matrix.m32 * vector.y + matrix.m13 * vector.z + matrix.m34;
            matrix.transform(vector, vector);
            TestUtil.COMPARE(expected.x, vector.x);
            TestUtil.COMPARE(expected.y, actual.y);
            TestUtil.COMPARE(expected.z, actual.z);
        }
Exemplo n.º 3
0
        public void transformTest()
        {
            LDVector3  vector   = new LDVector3();
            LDVector3  expected = new LDVector3();
            LDVector3  actual   = new LDVector3();
            LDMatrix44 matrix   = new LDMatrix44();

            //ld_float delta = 0.00001f;

            // Input : matrix = 単位行列, vector = 0.0 (ゼロ)
            vector.zero();
            expected.x = 0.0f;
            expected.y = 0.0f;
            expected.z = 0.0f;
            actual     = matrix.transform(vector);
            TestUtil.COMPARE(expected.x, actual.x);
            TestUtil.COMPARE(expected.y, actual.y);
            TestUtil.COMPARE(expected.z, actual.z);

            // Input : matrix = 任意の値, x = 1.0, y = 2.0, z = 3.0 (任意の値)
            vector.x   = 1.0f;
            vector.y   = 2.0f;
            vector.z   = 3.0f;
            matrix.m11 = 1.0f;
            matrix.m12 = 2.0f;
            matrix.m13 = 3.0f;
            matrix.m14 = 4.0f;
            matrix.m21 = 1.0f;
            matrix.m22 = 2.0f;
            matrix.m23 = 3.0f;
            matrix.m24 = 4.0f;
            matrix.m31 = 1.0f;
            matrix.m32 = 2.0f;
            matrix.m33 = 3.0f;
            matrix.m34 = 4.0f;
            expected.x = matrix.m11 * vector.x + matrix.m12 * vector.y + matrix.m13 * vector.z + matrix.m14;
            expected.y = matrix.m21 * vector.x + matrix.m22 * vector.y + matrix.m13 * vector.z + matrix.m24;
            expected.z = matrix.m31 * vector.y + matrix.m32 * vector.y + matrix.m13 * vector.z + matrix.m34;
            actual     = matrix.transform(vector);
            TestUtil.COMPARE(expected.x, actual.x);
            TestUtil.COMPARE(expected.y, actual.y);
            TestUtil.COMPARE(expected.z, actual.z);

            // Input : matrix = 任意の値, x = 1.0, y = 2.0, z = 3.0 (任意の値) (p == dstの場合)
            vector.x   = 1.0f;
            vector.y   = 2.0f;
            vector.z   = 3.0f;
            matrix.m11 = 1.0f;
            matrix.m12 = 2.0f;
            matrix.m13 = 3.0f;
            matrix.m14 = 4.0f;
            matrix.m21 = 1.0f;
            matrix.m22 = 2.0f;
            matrix.m23 = 3.0f;
            matrix.m24 = 4.0f;
            matrix.m31 = 1.0f;
            matrix.m32 = 2.0f;
            matrix.m33 = 3.0f;
            matrix.m34 = 4.0f;
            expected.x = matrix.m11 * vector.x + matrix.m12 * vector.y + matrix.m13 * vector.z + matrix.m14;
            expected.y = matrix.m21 * vector.x + matrix.m22 * vector.y + matrix.m13 * vector.z + matrix.m24;
            expected.z = matrix.m31 * vector.y + matrix.m32 * vector.y + matrix.m13 * vector.z + matrix.m34;
            matrix.transform(vector, vector);
            TestUtil.COMPARE(expected.x, vector.x);
            TestUtil.COMPARE(expected.y, actual.y);
            TestUtil.COMPARE(expected.z, actual.z);
        }