Beispiel #1
0
        /**
         * @brief オブジェクト空間->世界座標への変換行列をオイラー角に変換する(この行列は直交している必要がある)
         * @param &m Ematrix44をセットする
         */
        void fromObjectToWorldMatrix(LDMatrix44 m)
        {
            // m23からsin(pitch)を取り出す
            ld_float sp = -m.m23;

            // ジンバルロックのチェック
            if ((ld_float)Math.Abs(sp) > 1.0f - LDMathUtil.GINBAL_TOLERANCE)
            {
                //真上か真下
                pitch   = LDMathUtil.PI_OVER_2 * sp;
                heading = (ld_float)Math.Atan2(-m.m31, m.m11);
                bank    = 0.0f;
            }
            else
            {
                heading = (ld_float)Math.Atan2(m.m13, m.m33);
                pitch   = (ld_float)Math.Asin(sp);
                bank    = (ld_float)Math.Atan2(m.m21, m.m22);
            }

            /**
             * @brief 回転行列をオイラー角に変換する
             * @param &m RotationMatrixをセットする
             */
            //	void  fromRotationMatrix( const RotationMatrix &m ) ;
        }
Beispiel #2
0
        /**
         * @brief EMatrix44 * EMatrix44(コピーが発生するので、速度重視の場合は使わない)
         * @param m EMatrix44をセットする
         * @param p EMatrix44をセットする
         * @return EMatrix44 * EMatrix44を返す
         */
        public static LDMatrix44 operator *(LDMatrix44 a, LDMatrix44 b)
        {
            LDMatrix44 r = new LDMatrix44();

            //	dst[ 0] = a[ 0]*b[ 0] + a[ 4]*b[ 1] + a[ 8]*b[ 2] + a[12]*b[ 3] ;

            r.m11 = a.m11 * b.m11 + a.m12 * b.m21 + a.m13 * b.m31 + a.m14 * b.m41;
            r.m12 = a.m11 * b.m12 + a.m12 * b.m22 + a.m13 * b.m32 + a.m14 * b.m42;
            r.m13 = a.m11 * b.m13 + a.m12 * b.m23 + a.m13 * b.m33 + a.m14 * b.m43;
            r.m14 = a.m11 * b.m14 + a.m12 * b.m24 + a.m13 * b.m34 + a.m14 * b.m44;

            r.m21 = a.m21 * b.m11 + a.m22 * b.m21 + a.m23 * b.m31 + a.m24 * b.m41;
            r.m22 = a.m21 * b.m12 + a.m22 * b.m22 + a.m23 * b.m32 + a.m24 * b.m42;
            r.m23 = a.m21 * b.m13 + a.m22 * b.m23 + a.m23 * b.m33 + a.m24 * b.m43;
            r.m24 = a.m21 * b.m14 + a.m22 * b.m24 + a.m23 * b.m34 + a.m24 * b.m44;

            r.m31 = a.m31 * b.m11 + a.m32 * b.m21 + a.m33 * b.m31 + a.m34 * b.m41;
            r.m32 = a.m31 * b.m12 + a.m32 * b.m22 + a.m33 * b.m32 + a.m34 * b.m42;
            r.m33 = a.m31 * b.m13 + a.m32 * b.m23 + a.m33 * b.m33 + a.m34 * b.m43;
            r.m34 = a.m31 * b.m14 + a.m32 * b.m24 + a.m33 * b.m34 + a.m34 * b.m44;

            r.m41 = a.m41 * b.m11 + a.m42 * b.m21 + a.m43 * b.m31 + a.m44 * b.m41;
            r.m42 = a.m41 * b.m12 + a.m42 * b.m22 + a.m43 * b.m32 + a.m44 * b.m42;
            r.m43 = a.m41 * b.m13 + a.m42 * b.m23 + a.m43 * b.m33 + a.m44 * b.m43;
            r.m44 = a.m41 * b.m14 + a.m42 * b.m24 + a.m43 * b.m34 + a.m44 * b.m44;

            return(r);//コピーが発生するので、速度重視の場合は使わない
        }
Beispiel #3
0
 /// <summary>
 /// 行列を設定
 /// </summary>
 /// <param name="m2">EMatrix44をセットする</param>
 public void setMatrix(LDMatrix44 m2)
 {
     for (int i = 0; i < m2.m.Length; i++)
     {
         this.m[i] = m2.m[i];
     }
 }
Beispiel #4
0
        public void translateTest()
        {
            LDMatrix44 expected = new LDMatrix44();
            LDMatrix44 actual   = new LDMatrix44();

            //ld_float delta = 0.00001f;

            // Input : actual = 単位行列, x = 0.0, y = 0.0, z = 0.0 (ゼロ)
            actual.translate(0.0f, 0.0f, 0.0f);
            TestUtil.COMPARE(expected.m14, actual.m14);
            TestUtil.COMPARE(expected.m24, actual.m24);
            TestUtil.COMPARE(expected.m34, actual.m34);
            TestUtil.COMPARE(expected.m44, actual.m44);

            // Input : actual = 単位行列, x = 1.0, y = 2.0, z = 3.0 (任意の値)
            expected.m14 = 1.0f;
            expected.m24 = 2.0f;
            expected.m34 = 3.0f;
            expected.m44 = 1.0f;
            actual.translate(1.0f, 2.0f, 3.0f);
            TestUtil.COMPARE(expected.m14, actual.m14);
            TestUtil.COMPARE(expected.m24, actual.m24);
            TestUtil.COMPARE(expected.m34, actual.m34);
            TestUtil.COMPARE(expected.m44, actual.m44);

            // Input : actual = 任意の値, x = 1.0, y = 2.0, z = 3.0 (任意の値)
            ld_float x = 1.0f;
            ld_float y = 2.0f;
            ld_float z = 3.0f;

            actual.m11   = 1.0f;
            actual.m12   = 2.0f;
            actual.m13   = 3.0f;
            actual.m14   = 4.0f;
            actual.m21   = 1.0f;
            actual.m22   = 2.0f;
            actual.m23   = 3.0f;
            actual.m24   = 4.0f;
            actual.m31   = 1.0f;
            actual.m32   = 2.0f;
            actual.m33   = 3.0f;
            actual.m34   = 4.0f;
            actual.m41   = 1.0f;
            actual.m42   = 2.0f;
            actual.m43   = 3.0f;
            actual.m44   = 4.0f;
            expected.m14 = actual.m11 * x + actual.m12 * y + actual.m13 * z + actual.m14;
            expected.m24 = actual.m21 * x + actual.m22 * y + actual.m23 * z + actual.m24;
            expected.m34 = actual.m31 * x + actual.m32 * y + actual.m33 * z + actual.m34;
            expected.m44 = actual.m41 * x + actual.m42 * y + actual.m43 * z + actual.m44;
            actual.translate(x, y, z);
            TestUtil.COMPARE(expected.m14, actual.m14);
            TestUtil.COMPARE(expected.m24, actual.m24);
            TestUtil.COMPARE(expected.m34, actual.m34);
            TestUtil.COMPARE(expected.m44, actual.m44);
        }
Beispiel #5
0
        public void fromQuaterionTest()
        {
            LDQuat     quat     = new LDQuat(0.0f, 0.0f, 0.0f, 0.0f);
            LDMatrix44 expected = new LDMatrix44();
            LDMatrix44 actual   = new LDMatrix44();

            //ld_float delta = 0.00001f;

            // Input : actual = 単位行列, quat = 0.0 (ゼロ)
            actual.fromQuaterion(quat);
            TestUtil.COMPARE(expected.m11, actual.m11);
            TestUtil.COMPARE(expected.m12, actual.m12);
            TestUtil.COMPARE(expected.m13, actual.m13);
            TestUtil.COMPARE(expected.m21, actual.m21);
            TestUtil.COMPARE(expected.m22, actual.m22);
            TestUtil.COMPARE(expected.m23, actual.m23);
            TestUtil.COMPARE(expected.m31, actual.m31);
            TestUtil.COMPARE(expected.m32, actual.m32);
            TestUtil.COMPARE(expected.m33, actual.m33);
            TestUtil.COMPARE(expected.m41, actual.m41);
            TestUtil.COMPARE(expected.m42, actual.m42);
            TestUtil.COMPARE(expected.m43, actual.m43);

            // Input : actual = 単位行列, quat x = 1.0, y = 2.0, z = 3.0, w = 0.5 (任意の値)
            quat.x = 1.0f;
            quat.y = 2.0f;
            quat.z = 3.0f;
            quat.w = 0.5f;
            ld_float xx = 2.0f * quat.x;
            ld_float yy = 2.0f * quat.y;
            ld_float zz = 2.0f * quat.z;
            ld_float ww = -2.0f * quat.w;

            expected.m11 = 1.0f - yy * quat.y - zz * quat.z;
            expected.m12 = xx * quat.y + ww * quat.z;
            expected.m13 = xx * quat.z - ww * quat.y;
            expected.m21 = xx * quat.y - ww * quat.z;
            expected.m22 = 1.0f - xx * quat.x - zz * quat.z;
            expected.m23 = yy * quat.z + ww * quat.x;
            expected.m31 = xx * quat.z + ww * quat.y;
            expected.m32 = yy * quat.z - ww * quat.x;
            expected.m33 = 1.0f - xx * quat.x - yy * quat.y;
            actual.fromQuaterion(quat);
            TestUtil.COMPARE(expected.m11, actual.m11);
            TestUtil.COMPARE(expected.m12, actual.m12);
            TestUtil.COMPARE(expected.m13, actual.m13);
            TestUtil.COMPARE(expected.m21, actual.m21);
            TestUtil.COMPARE(expected.m22, actual.m22);
            TestUtil.COMPARE(expected.m23, actual.m23);
            TestUtil.COMPARE(expected.m31, actual.m31);
            TestUtil.COMPARE(expected.m32, actual.m32);
            TestUtil.COMPARE(expected.m33, actual.m33);
            TestUtil.COMPARE(expected.m41, actual.m41);
            TestUtil.COMPARE(expected.m42, actual.m42);
            TestUtil.COMPARE(expected.m43, actual.m43);
        }
Beispiel #6
0
        public void fromQuaterionTest()
        {
            LDQuat quat=new LDQuat(0.0f, 0.0f, 0.0f, 0.0f );
            LDMatrix44 expected = new LDMatrix44();
            LDMatrix44 actual = new LDMatrix44();
            //ld_float delta = 0.00001f;

            // Input : actual = 単位行列, quat = 0.0 (ゼロ)
            actual.fromQuaterion(quat);
            TestUtil.COMPARE(expected.m11, actual.m11);
            TestUtil.COMPARE(expected.m12, actual.m12);
            TestUtil.COMPARE(expected.m13, actual.m13);
            TestUtil.COMPARE(expected.m21, actual.m21);
            TestUtil.COMPARE(expected.m22, actual.m22);
            TestUtil.COMPARE(expected.m23, actual.m23);
            TestUtil.COMPARE(expected.m31, actual.m31);
            TestUtil.COMPARE(expected.m32, actual.m32);
            TestUtil.COMPARE(expected.m33, actual.m33);
            TestUtil.COMPARE(expected.m41, actual.m41);
            TestUtil.COMPARE(expected.m42, actual.m42);
            TestUtil.COMPARE(expected.m43, actual.m43);

            // Input : actual = 単位行列, quat x = 1.0, y = 2.0, z = 3.0, w = 0.5 (任意の値)
            quat.x = 1.0f;
            quat.y = 2.0f;
            quat.z = 3.0f;
            quat.w = 0.5f;
            ld_float xx = 2.0f * quat.x;
            ld_float yy = 2.0f * quat.y;
            ld_float zz = 2.0f * quat.z;
            ld_float ww = -2.0f * quat.w;
            expected.m11 = 1.0f - yy * quat.y - zz * quat.z;
            expected.m12 = xx * quat.y + ww * quat.z;
            expected.m13 = xx * quat.z - ww * quat.y;
            expected.m21 = xx * quat.y - ww * quat.z;
            expected.m22 = 1.0f - xx * quat.x - zz * quat.z;
            expected.m23 = yy * quat.z + ww * quat.x;
            expected.m31 = xx * quat.z + ww * quat.y;
            expected.m32 = yy * quat.z - ww * quat.x;
            expected.m33 = 1.0f - xx * quat.x - yy * quat.y;
            actual.fromQuaterion(quat);
            TestUtil.COMPARE(expected.m11, actual.m11);
            TestUtil.COMPARE(expected.m12, actual.m12);
            TestUtil.COMPARE(expected.m13, actual.m13);
            TestUtil.COMPARE(expected.m21, actual.m21);
            TestUtil.COMPARE(expected.m22, actual.m22);
            TestUtil.COMPARE(expected.m23, actual.m23);
            TestUtil.COMPARE(expected.m31, actual.m31);
            TestUtil.COMPARE(expected.m32, actual.m32);
            TestUtil.COMPARE(expected.m33, actual.m33);
            TestUtil.COMPARE(expected.m41, actual.m41);
            TestUtil.COMPARE(expected.m42, actual.m42);
            TestUtil.COMPARE(expected.m43, actual.m43);
        }
Beispiel #7
0
        //------ 演算 -------

        /**
         * @brief 受け取った2つの行列の掛け算を行う(指定の行列 m2 を右から掛け、dstに設定する)
         * @param b EMatrix44をセットする
         * @param *dst 変換行列を受け取るポインタをセットする
         */
        public void mult(LDMatrix44 b, LDMatrix44 dst, ld_bool omit4thRow = false)
        {
            //Debug.Assert(this != dst);

            if (this == dst)
            {
                mult_safe(this.m, b.m, dst.m, omit4thRow);
            }
            else
            {
                mult_fast(this.m, b.m, dst.m, omit4thRow);
            }
        }
Beispiel #8
0
        public void fromWorldToObjectMatrixTest()
        {
            LDMatrix44    matrix   = new LDMatrix44();
            LDEulerAngles actual   = new LDEulerAngles();
            LDEulerAngles expected = new LDEulerAngles();

            //ld_float delta = 0.00001f;

            // Input : (単位行列)
            actual.identity();
            expected.identity();
            actual.fromWorldToObjectMatrix(matrix);
            TestUtil.COMPARE(expected.heading, actual.heading);
            TestUtil.COMPARE(expected.pitch, actual.pitch);
            TestUtil.COMPARE(expected.bank, actual.bank);

            // Input : matrix.m23 = 1.0 (ジンバルロックのケース)
            matrix.m23       = 1.0f;
            expected.heading = (float)Math.Atan2(-matrix.m31, matrix.m11);
            expected.pitch   = LDMathUtil.PI_OVER_2 * -matrix.m23;
            expected.bank    = 0.0f;
            actual.fromWorldToObjectMatrix(matrix);
            TestUtil.COMPARE(expected.heading, actual.heading);
            TestUtil.COMPARE(expected.pitch, actual.pitch);
            TestUtil.COMPARE(expected.bank, actual.bank);

            // Input : matrix.m23 = 1.0 (任意の値. 角度計算のケース)
            matrix.m11       = 0.1f;
            matrix.m12       = 0.2f;
            matrix.m13       = 0.3f;
            matrix.m14       = 0.4f;
            matrix.m21       = 0.1f;
            matrix.m22       = 0.2f;
            matrix.m23       = 0.3f;
            matrix.m24       = 0.4f;
            matrix.m31       = 0.1f;
            matrix.m32       = 0.2f;
            matrix.m33       = 0.3f;
            matrix.m34       = 0.4f;
            matrix.m41       = 0.1f;
            matrix.m42       = 0.2f;
            matrix.m43       = 0.3f;
            matrix.m44       = 0.4f;
            expected.heading = (float)Math.Atan2(matrix.m13, matrix.m33);
            expected.pitch   = (float)Math.Asin(-matrix.m23);
            expected.bank    = (float)Math.Atan2(matrix.m21, matrix.m22);
            actual.fromWorldToObjectMatrix(matrix);
            TestUtil.COMPARE(expected.heading, actual.heading);
            TestUtil.COMPARE(expected.pitch, actual.pitch);
            TestUtil.COMPARE(expected.bank, actual.bank);
        }
Beispiel #9
0
        //------ EMatrix43.cpp ------
        public void identityTest()
        {
            LDMatrix44 actual   = new LDMatrix44();
            LDMatrix44 expected = new LDMatrix44();

            //ld_float delta = 0.00001f;

            // 単位行列に初期化できているかテスト
            expected.m11 = 1.0f;
            expected.m12 = 0.0f;
            expected.m13 = 0.0f;
            expected.m14 = 0.0f;
            expected.m21 = 0.0f;
            expected.m22 = 1.0f;
            expected.m23 = 0.0f;
            expected.m24 = 0.0f;
            expected.m31 = 0.0f;
            expected.m32 = 0.0f;
            expected.m33 = 1.0f;
            expected.m34 = 0.0f;
            expected.m41 = 0.0f;
            expected.m42 = 0.0f;
            expected.m43 = 0.0f;
            expected.m44 = 1.0f;
            actual.identity();
            TestUtil.COMPARE(expected.m11, actual.m11);
            TestUtil.COMPARE(expected.m12, actual.m12);
            TestUtil.COMPARE(expected.m13, actual.m13);
            TestUtil.COMPARE(expected.m14, actual.m14);
            TestUtil.COMPARE(expected.m21, actual.m21);
            TestUtil.COMPARE(expected.m22, actual.m22);
            TestUtil.COMPARE(expected.m23, actual.m23);
            TestUtil.COMPARE(expected.m24, actual.m24);
            TestUtil.COMPARE(expected.m31, actual.m31);
            TestUtil.COMPARE(expected.m32, actual.m32);
            TestUtil.COMPARE(expected.m33, actual.m33);
            TestUtil.COMPARE(expected.m34, actual.m34);
            TestUtil.COMPARE(expected.m41, actual.m41);
            TestUtil.COMPARE(expected.m42, actual.m42);
            TestUtil.COMPARE(expected.m43, actual.m43);
            TestUtil.COMPARE(expected.m44, actual.m44);
        }
Beispiel #10
0
        /**
         * @brief 世界座標->オブジェクト空間への変換行列をオイラー角に変換する(この行列は直交している必要がある)
         * @param &m Ematrix44をセットする
         */
        public void fromWorldToObjectMatrix(LDMatrix44 m)
        {
            // m23からsin(pitch)を取り出す
            ld_float sp = -m.m23;

            // ジンバルロックのチェック
            if ((ld_float)Math.Abs(sp) > 1.0f - LDMathUtil.GINBAL_TOLERANCE)
            {
                //真上か真下
                pitch   = LDMathUtil.PI_OVER_2 * sp;
                heading = (ld_float)Math.Atan2(-m.m31, m.m11);
                bank    = 0.0f;
            }
            else
            {
                heading = (ld_float)Math.Atan2(m.m13, m.m33);
                pitch   = (ld_float)Math.Asin(sp);
                bank    = (ld_float)Math.Atan2(m.m21, m.m22);
            }
        }
Beispiel #11
0
        //------ EMatrix43.cpp ------
        public void identityTest()
        {
            LDMatrix44 actual=new LDMatrix44();
            LDMatrix44 expected = new LDMatrix44();
            //ld_float delta = 0.00001f;

            // 単位行列に初期化できているかテスト
            expected.m11 = 1.0f;
            expected.m12 = 0.0f;
            expected.m13 = 0.0f;
            expected.m14 = 0.0f;
            expected.m21 = 0.0f;
            expected.m22 = 1.0f;
            expected.m23 = 0.0f;
            expected.m24 = 0.0f;
            expected.m31 = 0.0f;
            expected.m32 = 0.0f;
            expected.m33 = 1.0f;
            expected.m34 = 0.0f;
            expected.m41 = 0.0f;
            expected.m42 = 0.0f;
            expected.m43 = 0.0f;
            expected.m44 = 1.0f;
            actual.identity();
            TestUtil.COMPARE(expected.m11, actual.m11);
            TestUtil.COMPARE(expected.m12, actual.m12);
            TestUtil.COMPARE(expected.m13, actual.m13);
            TestUtil.COMPARE(expected.m14, actual.m14);
            TestUtil.COMPARE(expected.m21, actual.m21);
            TestUtil.COMPARE(expected.m22, actual.m22);
            TestUtil.COMPARE(expected.m23, actual.m23);
            TestUtil.COMPARE(expected.m24, actual.m24);
            TestUtil.COMPARE(expected.m31, actual.m31);
            TestUtil.COMPARE(expected.m32, actual.m32);
            TestUtil.COMPARE(expected.m33, actual.m33);
            TestUtil.COMPARE(expected.m34, actual.m34);
            TestUtil.COMPARE(expected.m41, actual.m41);
            TestUtil.COMPARE(expected.m42, actual.m42);
            TestUtil.COMPARE(expected.m43, actual.m43);
            TestUtil.COMPARE(expected.m44, actual.m44);
        }
Beispiel #12
0
 /**
 * @brief オブジェクト空間->世界座標への変換行列をオイラー角に変換する(この行列は直交している必要がある)
 * @param &m Ematrix44をセットする
 */
 public void fromObjectToWorldMatrix(LDMatrix44 m)
 {
     throw new NotImplementedException();
 }
Beispiel #13
0
        /**
        * @brief 世界座標->オブジェクト空間への変換行列をオイラー角に変換する(この行列は直交している必要がある)
        * @param &m Ematrix44をセットする
        */
        public void fromWorldToObjectMatrix(LDMatrix44 m)
        {
            // m23からsin(pitch)を取り出す
            ld_float sp = -m.m23;

            // ジンバルロックのチェック
            if ((ld_float)Math.Abs(sp) > 1.0f - LDMathUtil.GINBAL_TOLERANCE)
            {
                //真上か真下
                pitch = LDMathUtil.PI_OVER_2 * sp;
                heading = (ld_float)Math.Atan2(-m.m31, m.m11);
                bank = 0.0f;
            }
            else
            {
                heading = (ld_float)Math.Atan2(m.m13, m.m33);
                pitch = (ld_float)Math.Asin(sp);
                bank = (ld_float)Math.Atan2(m.m21, m.m22);
            }
        }
Beispiel #14
0
        public void rotateZTest()
        {
            LDMatrix44 expected = new LDMatrix44();
            LDMatrix44 actual   = new LDMatrix44();
            //ld_float delta = 0.00001f;
            ld_float tmp;
            ld_float theta;

            // Input : actual = 単位行列, theta = 0.0 (ゼロ)
            tmp          = expected.m11;
            expected.m11 = tmp * (float)Math.Cos(0.0f) + expected.m12 * (float)Math.Sin(0.0f);
            expected.m12 = tmp * -(float)Math.Sin(0.0f) + expected.m12 * (float)Math.Cos(0.0f);
            tmp          = expected.m21;
            expected.m21 = tmp * (float)Math.Cos(0.0f) + expected.m22 * (float)Math.Sin(0.0f);
            expected.m22 = tmp * -(float)Math.Sin(0.0f) + expected.m22 * (float)Math.Cos(0.0f);
            tmp          = expected.m31;
            expected.m31 = tmp * (float)Math.Cos(0.0f) + expected.m32 * (float)Math.Sin(0.0f);
            expected.m32 = tmp * -(float)Math.Sin(0.0f) + expected.m32 * (float)Math.Cos(0.0f);
            tmp          = expected.m41;
            expected.m41 = tmp * (float)Math.Cos(0.0f) + expected.m32 * (float)Math.Sin(0.0f);
            expected.m42 = tmp * -(float)Math.Sin(0.0f) + expected.m32 * (float)Math.Cos(0.0f);
            actual.rotateZ(0.0f);
            TestUtil.COMPARE(expected.m11, actual.m11);
            TestUtil.COMPARE(expected.m12, actual.m12);
            TestUtil.COMPARE(expected.m13, actual.m13);
            TestUtil.COMPARE(expected.m21, actual.m21);
            TestUtil.COMPARE(expected.m22, actual.m22);
            TestUtil.COMPARE(expected.m23, actual.m23);
            TestUtil.COMPARE(expected.m31, actual.m31);
            TestUtil.COMPARE(expected.m32, actual.m32);
            TestUtil.COMPARE(expected.m33, actual.m33);
            TestUtil.COMPARE(expected.m41, actual.m41);
            TestUtil.COMPARE(expected.m42, actual.m42);
            TestUtil.COMPARE(expected.m43, actual.m43);

            // Input : actual = 任意の値, theta = PI/4.0f; (任意の値)
            theta        = LDMathUtil.PI / 4.0f;
            actual.m11   = 1.0f;
            actual.m12   = 2.0f;
            actual.m13   = 3.0f;
            actual.m21   = 1.0f;
            actual.m22   = 2.0f;
            actual.m23   = 3.0f;
            actual.m31   = 1.0f;
            actual.m32   = 2.0f;
            actual.m33   = 3.0f;
            actual.m41   = 1.0f;
            actual.m42   = 2.0f;
            actual.m43   = 3.0f;
            expected.m11 = 1.0f;
            expected.m12 = 2.0f;
            expected.m13 = 3.0f;
            expected.m21 = 1.0f;
            expected.m22 = 2.0f;
            expected.m23 = 3.0f;
            expected.m31 = 1.0f;
            expected.m32 = 2.0f;
            expected.m33 = 3.0f;
            expected.m41 = 1.0f;
            expected.m42 = 2.0f;
            expected.m43 = 3.0f;
            tmp          = expected.m11;
            expected.m11 = tmp * (float)Math.Cos(theta) + expected.m12 * (float)Math.Sin(theta);
            expected.m12 = tmp * -(float)Math.Sin(theta) + expected.m12 * (float)Math.Cos(theta);
            tmp          = expected.m21;
            expected.m21 = tmp * (float)Math.Cos(theta) + expected.m22 * (float)Math.Sin(theta);
            expected.m22 = tmp * -(float)Math.Sin(theta) + expected.m22 * (float)Math.Cos(theta);
            tmp          = expected.m31;
            expected.m31 = tmp * (float)Math.Cos(theta) + expected.m32 * (float)Math.Sin(theta);
            expected.m32 = tmp * -(float)Math.Sin(theta) + expected.m32 * (float)Math.Cos(theta);
            tmp          = expected.m41;
            expected.m41 = tmp * (float)Math.Cos(theta) + expected.m42 * (float)Math.Sin(theta);
            expected.m42 = tmp * -(float)Math.Sin(theta) + expected.m42 * (float)Math.Cos(theta);
            actual.rotateZ(theta);
            TestUtil.COMPARE(expected.m11, actual.m11);
            TestUtil.COMPARE(expected.m12, actual.m12);
            TestUtil.COMPARE(expected.m13, actual.m13);
            TestUtil.COMPARE(expected.m21, actual.m21);
            TestUtil.COMPARE(expected.m22, actual.m22);
            TestUtil.COMPARE(expected.m23, actual.m23);
            TestUtil.COMPARE(expected.m31, actual.m31);
            TestUtil.COMPARE(expected.m32, actual.m32);
            TestUtil.COMPARE(expected.m33, actual.m33);
            TestUtil.COMPARE(expected.m41, actual.m41);
            TestUtil.COMPARE(expected.m42, actual.m42);
            TestUtil.COMPARE(expected.m43, actual.m43);
        }
Beispiel #15
0
        public void fromWorldToObjectMatrixTest()
        {
            LDMatrix44 matrix=new LDMatrix44();
            LDEulerAngles actual=new LDEulerAngles();
            LDEulerAngles expected=new LDEulerAngles();
            //ld_float delta = 0.00001f;

            // Input : (単位行列)
            actual.identity();
            expected.identity();
            actual.fromWorldToObjectMatrix(matrix);
            TestUtil.COMPARE(expected.heading, actual.heading);
            TestUtil.COMPARE(expected.pitch, actual.pitch);
            TestUtil.COMPARE(expected.bank, actual.bank);

            // Input : matrix.m23 = 1.0 (ジンバルロックのケース)
            matrix.m23 = 1.0f;
            expected.heading = (float)Math.Atan2(-matrix.m31, matrix.m11);
            expected.pitch = LDMathUtil.PI_OVER_2 * -matrix.m23;
            expected.bank = 0.0f;
            actual.fromWorldToObjectMatrix(matrix);
            TestUtil.COMPARE(expected.heading, actual.heading);
            TestUtil.COMPARE(expected.pitch, actual.pitch);
            TestUtil.COMPARE(expected.bank, actual.bank);

            // Input : matrix.m23 = 1.0 (任意の値. 角度計算のケース)
            matrix.m11 = 0.1f;
            matrix.m12 = 0.2f;
            matrix.m13 = 0.3f;
            matrix.m14 = 0.4f;
            matrix.m21 = 0.1f;
            matrix.m22 = 0.2f;
            matrix.m23 = 0.3f;
            matrix.m24 = 0.4f;
            matrix.m31 = 0.1f;
            matrix.m32 = 0.2f;
            matrix.m33 = 0.3f;
            matrix.m34 = 0.4f;
            matrix.m41 = 0.1f;
            matrix.m42 = 0.2f;
            matrix.m43 = 0.3f;
            matrix.m44 = 0.4f;
            expected.heading = (float)Math.Atan2(matrix.m13, matrix.m33);
            expected.pitch = (float)Math.Asin(-matrix.m23);
            expected.bank = (float)Math.Atan2(matrix.m21, matrix.m22);
            actual.fromWorldToObjectMatrix(matrix);
            TestUtil.COMPARE(expected.heading, actual.heading);
            TestUtil.COMPARE(expected.pitch, actual.pitch);
            TestUtil.COMPARE(expected.bank, actual.bank);
        }
Beispiel #16
0
 /// <summary>
 /// 行列式 未実装
 /// </summary>
 /// <param name="m">EMatrix44をセットする</param>
 /// <returns>行列式を返す</returns>
 public ld_float det(LDMatrix44 m)
 {
     throw new NotImplementedException();
 }
Beispiel #17
0
 /// <summary>
 /// 逆行列 未実装
 /// </summary>
 /// <param name="m">EMatrix44をセットする</param>
 /// <returns>逆行列を返す</returns>
 public LDMatrix44 inverse(LDMatrix44 m)
 {
     throw new NotImplementedException();
 }
Beispiel #18
0
 /**
  * @brief オブジェクト空間->世界座標への変換行列をオイラー角に変換する(この行列は直交している必要がある)
  * @param &m Ematrix44をセットする
  */
 public void fromObjectToWorldMatrix(LDMatrix44 m)
 {
     throw new NotImplementedException();
 }
Beispiel #19
0
        public void scaleTest()
        {
            LDMatrix44 expected = new LDMatrix44();
            LDMatrix44 actual   = new LDMatrix44();

            //ld_float delta = 0.00001f;

            // Input : actual = 単位行列, x = 0.0, y = 0.0, z = 0.0 (ゼロ)
            expected.m11 = 0.0f;
            expected.m12 = 0.0f;
            expected.m13 = 0.0f;
            expected.m21 = 0.0f;
            expected.m22 = 0.0f;
            expected.m23 = 0.0f;
            expected.m31 = 0.0f;
            expected.m32 = 0.0f;
            expected.m33 = 0.0f;
            expected.m41 = 0.0f;
            expected.m42 = 0.0f;
            expected.m43 = 0.0f;
            actual.scale(0.0f, 0.0f, 0.0f);
            TestUtil.COMPARE(expected.m11, actual.m11);
            TestUtil.COMPARE(expected.m12, actual.m12);
            TestUtil.COMPARE(expected.m13, actual.m13);
            TestUtil.COMPARE(expected.m21, actual.m21);
            TestUtil.COMPARE(expected.m22, actual.m22);
            TestUtil.COMPARE(expected.m23, actual.m23);
            TestUtil.COMPARE(expected.m31, actual.m31);
            TestUtil.COMPARE(expected.m32, actual.m32);
            TestUtil.COMPARE(expected.m33, actual.m33);
            TestUtil.COMPARE(expected.m41, actual.m41);
            TestUtil.COMPARE(expected.m42, actual.m42);
            TestUtil.COMPARE(expected.m43, actual.m43);

            // Input : actual = 任意の値, x = 1.0, y = 2.0, z = 3.0 (任意の値)
            ld_float x = 1.0f;
            ld_float y = 2.0f;
            ld_float z = 3.0f;

            actual.m11   = 1.0f;
            actual.m12   = 2.0f;
            actual.m13   = 3.0f;
            actual.m21   = 1.0f;
            actual.m22   = 2.0f;
            actual.m23   = 3.0f;
            actual.m31   = 1.0f;
            actual.m32   = 2.0f;
            actual.m33   = 3.0f;
            actual.m41   = 1.0f;
            actual.m42   = 2.0f;
            actual.m43   = 3.0f;
            expected.m11 = actual.m11 * x;
            expected.m12 = actual.m12 * y;
            expected.m13 = actual.m13 * z;
            expected.m21 = actual.m21 * x;
            expected.m22 = actual.m22 * y;
            expected.m23 = actual.m23 * z;
            expected.m31 = actual.m31 * x;
            expected.m32 = actual.m32 * y;
            expected.m33 = actual.m33 * z;
            expected.m41 = actual.m41 * x;
            expected.m42 = actual.m42 * y;
            expected.m43 = actual.m43 * z;
            actual.scale(x, y, z);
            TestUtil.COMPARE(expected.m11, actual.m11);
            TestUtil.COMPARE(expected.m12, actual.m12);
            TestUtil.COMPARE(expected.m13, actual.m13);
            TestUtil.COMPARE(expected.m21, actual.m21);
            TestUtil.COMPARE(expected.m22, actual.m22);
            TestUtil.COMPARE(expected.m23, actual.m23);
            TestUtil.COMPARE(expected.m31, actual.m31);
            TestUtil.COMPARE(expected.m32, actual.m32);
            TestUtil.COMPARE(expected.m33, actual.m33);
            TestUtil.COMPARE(expected.m41, actual.m41);
            TestUtil.COMPARE(expected.m42, actual.m42);
            TestUtil.COMPARE(expected.m43, actual.m43);
        }
Beispiel #20
0
        public void multTest()
        {
            LDMatrix44 matrix1 = new LDMatrix44();
            LDMatrix44 matrix2 = new LDMatrix44();
            LDMatrix44 expected = new LDMatrix44();
            LDMatrix44 actual = new LDMatrix44();
            //ld_float delta = 0.00001f;

            // Input : matrix1 = 単位行列, matrix2 = 単位行列 (mult_fastのテスト)
            matrix1.mult(matrix2, actual);
            TestUtil.COMPARE(expected.m11, actual.m11);
            TestUtil.COMPARE(expected.m12, actual.m12);
            TestUtil.COMPARE(expected.m13, actual.m13);
            TestUtil.COMPARE(expected.m14, actual.m14);
            TestUtil.COMPARE(expected.m21, actual.m21);
            TestUtil.COMPARE(expected.m22, actual.m22);
            TestUtil.COMPARE(expected.m23, actual.m23);
            TestUtil.COMPARE(expected.m24, actual.m24);
            TestUtil.COMPARE(expected.m31, actual.m31);
            TestUtil.COMPARE(expected.m32, actual.m32);
            TestUtil.COMPARE(expected.m33, actual.m33);
            TestUtil.COMPARE(expected.m34, actual.m34);
            TestUtil.COMPARE(expected.m41, actual.m41);
            TestUtil.COMPARE(expected.m42, actual.m42);
            TestUtil.COMPARE(expected.m43, actual.m43);
            TestUtil.COMPARE(expected.m44, actual.m44);

            // Input : matrix1, matrix2 = 任意の値 (mult_fastのテスト)
            matrix1.m11 = 1.0f;
            matrix1.m12 = 2.0f;
            matrix1.m13 = 3.0f;
            matrix1.m14 = 4.0f;
            matrix1.m21 = 1.0f;
            matrix1.m22 = 2.0f;
            matrix1.m23 = 3.0f;
            matrix1.m24 = 4.0f;
            matrix1.m31 = 1.0f;
            matrix1.m32 = 2.0f;
            matrix1.m33 = 3.0f;
            matrix1.m34 = 4.0f;
            matrix1.m41 = 1.0f;
            matrix1.m42 = 2.0f;
            matrix1.m43 = 3.0f;
            matrix1.m44 = 4.0f;
            matrix2.m11 = 1.0f;
            matrix2.m12 = 2.0f;
            matrix2.m13 = 3.0f;
            matrix2.m14 = 4.0f;
            matrix2.m21 = 1.0f;
            matrix2.m22 = 2.0f;
            matrix2.m23 = 3.0f;
            matrix2.m24 = 4.0f;
            matrix2.m31 = 1.0f;
            matrix2.m32 = 2.0f;
            matrix2.m33 = 3.0f;
            matrix2.m34 = 4.0f;
            matrix2.m41 = 1.0f;
            matrix2.m42 = 2.0f;
            matrix2.m43 = 3.0f;
            matrix2.m44 = 4.0f;
            expected.m[0] = matrix1.m[0] * matrix2.m[0] + matrix1.m[4] * matrix2.m[1] +
                            matrix1.m[8] * matrix2.m[2] + matrix1.m[12] * matrix2.m[3];
            expected.m[1] = matrix1.m[1] * matrix2.m[0] + matrix1.m[5] * matrix2.m[1] +
                            matrix1.m[9] * matrix2.m[2] + matrix1.m[13] * matrix2.m[3];
            expected.m[2] = matrix1.m[2] * matrix2.m[0] + matrix1.m[6] * matrix2.m[1] +
                            matrix1.m[10] * matrix2.m[2] + matrix1.m[14] * matrix2.m[3];
            expected.m[3] = matrix1.m[3] * matrix2.m[0] + matrix1.m[7] * matrix2.m[1] +
                            matrix1.m[11] * matrix2.m[2] + matrix1.m[15] * matrix2.m[3];
            expected.m[4] = matrix1.m[0] * matrix2.m[4] + matrix1.m[4] * matrix2.m[5] +
                            matrix1.m[8] * matrix2.m[6] + matrix1.m[12] * matrix2.m[7];
            expected.m[5] = matrix1.m[1] * matrix2.m[4] + matrix1.m[5] * matrix2.m[5] +
                            matrix1.m[9] * matrix2.m[6] + matrix1.m[13] * matrix2.m[7];
            expected.m[6] = matrix1.m[2] * matrix2.m[4] + matrix1.m[6] * matrix2.m[5] +
                            matrix1.m[10] * matrix2.m[6] + matrix1.m[14] * matrix2.m[7];
            expected.m[7] = matrix1.m[3] * matrix2.m[4] + matrix1.m[7] * matrix2.m[5] +
                            matrix1.m[11] * matrix2.m[6] + matrix1.m[15] * matrix2.m[7];
            expected.m[8] = matrix1.m[0] * matrix2.m[8] + matrix1.m[4] * matrix2.m[9] +
                            matrix1.m[8] * matrix2.m[10] + matrix1.m[12] * matrix2.m[11];
            expected.m[9] = matrix1.m[1] * matrix2.m[8] + matrix1.m[5] * matrix2.m[9] +
                            matrix1.m[9] * matrix2.m[10] + matrix1.m[13] * matrix2.m[11];
            expected.m[10] = matrix1.m[2] * matrix2.m[8] + matrix1.m[6] * matrix2.m[9] +
                            matrix1.m[10] * matrix2.m[10] + matrix1.m[14] * matrix2.m[11];
            expected.m[11] = matrix1.m[3] * matrix2.m[8] + matrix1.m[7] * matrix2.m[9] +
                            matrix1.m[11] * matrix2.m[10] + matrix1.m[15] * matrix2.m[11];
            expected.m[12] = matrix1.m[0] * matrix2.m[12] + matrix1.m[4] * matrix2.m[13] +
                            matrix1.m[8] * matrix2.m[14] + matrix1.m[12] * matrix2.m[15];
            expected.m[13] = matrix1.m[1] * matrix2.m[12] + matrix1.m[5] * matrix2.m[13] +
                            matrix1.m[9] * matrix2.m[14] + matrix1.m[13] * matrix2.m[15];
            expected.m[14] = matrix1.m[2] * matrix2.m[12] + matrix1.m[6] * matrix2.m[13] +
                            matrix1.m[10] * matrix2.m[14] + matrix1.m[14] * matrix2.m[15];
            expected.m[15] = matrix1.m[3] * matrix2.m[12] + matrix1.m[7] * matrix2.m[13] +
                            matrix1.m[11] * matrix2.m[14] + matrix1.m[15] * matrix2.m[15];

            matrix1.mult(matrix2, actual);
            TestUtil.COMPARE(expected.m11, actual.m11);
            TestUtil.COMPARE(expected.m12, actual.m12);
            TestUtil.COMPARE(expected.m13, actual.m13);
            TestUtil.COMPARE(expected.m14, actual.m14);
            TestUtil.COMPARE(expected.m21, actual.m21);
            TestUtil.COMPARE(expected.m22, actual.m22);
            TestUtil.COMPARE(expected.m23, actual.m23);
            TestUtil.COMPARE(expected.m24, actual.m24);
            TestUtil.COMPARE(expected.m31, actual.m31);
            TestUtil.COMPARE(expected.m32, actual.m32);
            TestUtil.COMPARE(expected.m33, actual.m33);
            TestUtil.COMPARE(expected.m34, actual.m34);
            TestUtil.COMPARE(expected.m41, actual.m41);
            TestUtil.COMPARE(expected.m42, actual.m42);
            TestUtil.COMPARE(expected.m43, actual.m43);
            TestUtil.COMPARE(expected.m44, actual.m44);

            // Input : matrix1, matrix2 = 任意の値 (mult_safeのテスト) <- assertのため分岐できず
            //matrix1.mult(matrix2, &matrix1);
        }
Beispiel #21
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);
        }
Beispiel #22
0
        public void setMatrixTest()
        {
            LDMatrix44 matrix=new LDMatrix44();
            LDMatrix44 actual = new LDMatrix44();
            LDMatrix44 expected = new LDMatrix44();
            //ld_float delta = 0.00001f;
            ld_float[] m=new ld_float[16];

            // EMatrix44.setMatrix( const ld_float* _m ) のテスト
            for (int i = 0; i < 16; ++i)
            {
                m[i] = 1.0f;
            }
            actual.setMatrix(m);
            expected.m11 = 1.0f;
            expected.m12 = 1.0f;
            expected.m13 = 1.0f;
            expected.m14 = 1.0f;
            expected.m21 = 1.0f;
            expected.m22 = 1.0f;
            expected.m23 = 1.0f;
            expected.m24 = 1.0f;
            expected.m31 = 1.0f;
            expected.m32 = 1.0f;
            expected.m33 = 1.0f;
            expected.m34 = 1.0f;
            expected.m41 = 1.0f;
            expected.m42 = 1.0f;
            expected.m43 = 1.0f;
            expected.m44 = 1.0f;
            TestUtil.COMPARE(expected.m11, actual.m11);
            TestUtil.COMPARE(expected.m12, actual.m12);
            TestUtil.COMPARE(expected.m13, actual.m13);
            TestUtil.COMPARE(expected.m14, actual.m14);
            TestUtil.COMPARE(expected.m21, actual.m21);
            TestUtil.COMPARE(expected.m22, actual.m22);
            TestUtil.COMPARE(expected.m23, actual.m23);
            TestUtil.COMPARE(expected.m24, actual.m24);
            TestUtil.COMPARE(expected.m31, actual.m31);
            TestUtil.COMPARE(expected.m32, actual.m32);
            TestUtil.COMPARE(expected.m33, actual.m33);
            TestUtil.COMPARE(expected.m34, actual.m34);
            TestUtil.COMPARE(expected.m41, actual.m41);
            TestUtil.COMPARE(expected.m42, actual.m42);
            TestUtil.COMPARE(expected.m43, actual.m43);
            TestUtil.COMPARE(expected.m44, actual.m44);

            // EMatrix43.setMatrix( const EMatrix43 &m2 ) のテスト
            for (int i = 0; i < 16; ++i)
            {
                m[i] = 2.0f;
            }
            matrix.setMatrix(m);
            actual.setMatrix(matrix);
            expected.m11 = 2.0f;
            expected.m12 = 2.0f;
            expected.m13 = 2.0f;
            expected.m14 = 2.0f;
            expected.m21 = 2.0f;
            expected.m22 = 2.0f;
            expected.m23 = 2.0f;
            expected.m24 = 2.0f;
            expected.m31 = 2.0f;
            expected.m32 = 2.0f;
            expected.m33 = 2.0f;
            expected.m34 = 2.0f;
            expected.m41 = 2.0f;
            expected.m42 = 2.0f;
            expected.m43 = 2.0f;
            expected.m44 = 2.0f;
            TestUtil.COMPARE(expected.m11, actual.m11);
            TestUtil.COMPARE(expected.m12, actual.m12);
            TestUtil.COMPARE(expected.m13, actual.m13);
            TestUtil.COMPARE(expected.m14, actual.m14);
            TestUtil.COMPARE(expected.m21, actual.m21);
            TestUtil.COMPARE(expected.m22, actual.m22);
            TestUtil.COMPARE(expected.m23, actual.m23);
            TestUtil.COMPARE(expected.m24, actual.m24);
            TestUtil.COMPARE(expected.m31, actual.m31);
            TestUtil.COMPARE(expected.m32, actual.m32);
            TestUtil.COMPARE(expected.m33, actual.m33);
            TestUtil.COMPARE(expected.m34, actual.m34);
            TestUtil.COMPARE(expected.m41, actual.m41);
            TestUtil.COMPARE(expected.m42, actual.m42);
            TestUtil.COMPARE(expected.m43, actual.m43);
            TestUtil.COMPARE(expected.m44, actual.m44);
        }
Beispiel #23
0
        public void rotateZTest()
        {
            LDMatrix44 expected = new LDMatrix44();
            LDMatrix44 actual = new LDMatrix44();
            //ld_float delta = 0.00001f;
            ld_float tmp;
            ld_float theta;

            // Input : actual = 単位行列, theta = 0.0 (ゼロ)
            tmp = expected.m11;
            expected.m11 = tmp * (float)Math.Cos(0.0f) + expected.m12 * (float)Math.Sin(0.0f);
            expected.m12 = tmp * -(float)Math.Sin(0.0f) + expected.m12 * (float)Math.Cos(0.0f);
            tmp = expected.m21;
            expected.m21 = tmp * (float)Math.Cos(0.0f) + expected.m22 * (float)Math.Sin(0.0f);
            expected.m22 = tmp * -(float)Math.Sin(0.0f) + expected.m22 * (float)Math.Cos(0.0f);
            tmp = expected.m31;
            expected.m31 = tmp * (float)Math.Cos(0.0f) + expected.m32 * (float)Math.Sin(0.0f);
            expected.m32 = tmp * -(float)Math.Sin(0.0f) + expected.m32 * (float)Math.Cos(0.0f);
            tmp = expected.m41;
            expected.m41 = tmp * (float)Math.Cos(0.0f) + expected.m32 * (float)Math.Sin(0.0f);
            expected.m42 = tmp * -(float)Math.Sin(0.0f) + expected.m32 * (float)Math.Cos(0.0f);
            actual.rotateZ(0.0f);
            TestUtil.COMPARE(expected.m11, actual.m11);
            TestUtil.COMPARE(expected.m12, actual.m12);
            TestUtil.COMPARE(expected.m13, actual.m13);
            TestUtil.COMPARE(expected.m21, actual.m21);
            TestUtil.COMPARE(expected.m22, actual.m22);
            TestUtil.COMPARE(expected.m23, actual.m23);
            TestUtil.COMPARE(expected.m31, actual.m31);
            TestUtil.COMPARE(expected.m32, actual.m32);
            TestUtil.COMPARE(expected.m33, actual.m33);
            TestUtil.COMPARE(expected.m41, actual.m41);
            TestUtil.COMPARE(expected.m42, actual.m42);
            TestUtil.COMPARE(expected.m43, actual.m43);

            // Input : actual = 任意の値, theta = PI/4.0f; (任意の値)
            theta = LDMathUtil.PI / 4.0f;
            actual.m11 = 1.0f;
            actual.m12 = 2.0f;
            actual.m13 = 3.0f;
            actual.m21 = 1.0f;
            actual.m22 = 2.0f;
            actual.m23 = 3.0f;
            actual.m31 = 1.0f;
            actual.m32 = 2.0f;
            actual.m33 = 3.0f;
            actual.m41 = 1.0f;
            actual.m42 = 2.0f;
            actual.m43 = 3.0f;
            expected.m11 = 1.0f;
            expected.m12 = 2.0f;
            expected.m13 = 3.0f;
            expected.m21 = 1.0f;
            expected.m22 = 2.0f;
            expected.m23 = 3.0f;
            expected.m31 = 1.0f;
            expected.m32 = 2.0f;
            expected.m33 = 3.0f;
            expected.m41 = 1.0f;
            expected.m42 = 2.0f;
            expected.m43 = 3.0f;
            tmp = expected.m11;
            expected.m11 = tmp * (float)Math.Cos(theta) + expected.m12 * (float)Math.Sin(theta);
            expected.m12 = tmp * -(float)Math.Sin(theta) + expected.m12 * (float)Math.Cos(theta);
            tmp = expected.m21;
            expected.m21 = tmp * (float)Math.Cos(theta) + expected.m22 * (float)Math.Sin(theta);
            expected.m22 = tmp * -(float)Math.Sin(theta) + expected.m22 * (float)Math.Cos(theta);
            tmp = expected.m31;
            expected.m31 = tmp * (float)Math.Cos(theta) + expected.m32 * (float)Math.Sin(theta);
            expected.m32 = tmp * -(float)Math.Sin(theta) + expected.m32 * (float)Math.Cos(theta);
            tmp = expected.m41;
            expected.m41 = tmp * (float)Math.Cos(theta) + expected.m42 * (float)Math.Sin(theta);
            expected.m42 = tmp * -(float)Math.Sin(theta) + expected.m42 * (float)Math.Cos(theta);
            actual.rotateZ(theta);
            TestUtil.COMPARE(expected.m11, actual.m11);
            TestUtil.COMPARE(expected.m12, actual.m12);
            TestUtil.COMPARE(expected.m13, actual.m13);
            TestUtil.COMPARE(expected.m21, actual.m21);
            TestUtil.COMPARE(expected.m22, actual.m22);
            TestUtil.COMPARE(expected.m23, actual.m23);
            TestUtil.COMPARE(expected.m31, actual.m31);
            TestUtil.COMPARE(expected.m32, actual.m32);
            TestUtil.COMPARE(expected.m33, actual.m33);
            TestUtil.COMPARE(expected.m41, actual.m41);
            TestUtil.COMPARE(expected.m42, actual.m42);
            TestUtil.COMPARE(expected.m43, actual.m43);
        }
Beispiel #24
0
        //------ 演算 -------
        /**
        * @brief 受け取った2つの行列の掛け算を行う(指定の行列 m2 を右から掛け、dstに設定する)
        * @param b EMatrix44をセットする
        * @param *dst 変換行列を受け取るポインタをセットする
*/
        public void mult(LDMatrix44 b, LDMatrix44 dst, ld_bool omit4thRow = false)
        {
            Debug.Assert(this != dst);

            if (this == dst)
            {
                mult_safe(this.m, b.m, dst.m, omit4thRow);
            }
            else
            {
                mult_fast(this.m, b.m, dst.m, omit4thRow);
            }
        }
Beispiel #25
0
 /// <summary>
 /// 行列を設定
 /// </summary>
 /// <param name="m2">EMatrix44をセットする</param>
 public void setMatrix(LDMatrix44 m2)
 {
     for (int i = 0; i < m2.m.Length; i++)
     {
         this.m[i] = m2.m[i];
     }
 }
Beispiel #26
0
        /**
        * @brief オブジェクト空間->世界座標への変換行列をオイラー角に変換する(この行列は直交している必要がある)
        * @param &m Ematrix44をセットする
        */
        void fromObjectToWorldMatrix(LDMatrix44 m)
        {
            // m23からsin(pitch)を取り出す
            ld_float sp = -m.m23;

            // ジンバルロックのチェック
            if ((ld_float)Math.Abs(sp) > 1.0f - LDMathUtil.GINBAL_TOLERANCE)
            {
                //真上か真下
                pitch = LDMathUtil.PI_OVER_2 * sp;
                heading = (ld_float)Math.Atan2(-m.m31, m.m11);
                bank = 0.0f;
            }
            else
            {
                heading = (ld_float)Math.Atan2(m.m13, m.m33);
                pitch = (ld_float)Math.Asin(sp);
                bank = (ld_float)Math.Atan2(m.m21, m.m22);
            }

            /**
            * @brief 回転行列をオイラー角に変換する
            * @param &m RotationMatrixをセットする
            */
            //	void  fromRotationMatrix( const RotationMatrix &m ) ;
        }
Beispiel #27
0
        /**
        * @brief EMatrix44 * EMatrix44(コピーが発生するので、速度重視の場合は使わない)
        * @param m EMatrix44をセットする
        * @param p EMatrix44をセットする
        * @return EMatrix44 * EMatrix44を返す
*/
        public static LDMatrix44 operator *(LDMatrix44 a, LDMatrix44 b)
        {
            LDMatrix44 r = new LDMatrix44();
            //	dst[ 0] = a[ 0]*b[ 0] + a[ 4]*b[ 1] + a[ 8]*b[ 2] + a[12]*b[ 3] ;

            r.m11 = a.m11 * b.m11 + a.m12 * b.m21 + a.m13 * b.m31 + a.m14 * b.m41;
            r.m12 = a.m11 * b.m12 + a.m12 * b.m22 + a.m13 * b.m32 + a.m14 * b.m42;
            r.m13 = a.m11 * b.m13 + a.m12 * b.m23 + a.m13 * b.m33 + a.m14 * b.m43;
            r.m14 = a.m11 * b.m14 + a.m12 * b.m24 + a.m13 * b.m34 + a.m14 * b.m44;

            r.m21 = a.m21 * b.m11 + a.m22 * b.m21 + a.m23 * b.m31 + a.m24 * b.m41;
            r.m22 = a.m21 * b.m12 + a.m22 * b.m22 + a.m23 * b.m32 + a.m24 * b.m42;
            r.m23 = a.m21 * b.m13 + a.m22 * b.m23 + a.m23 * b.m33 + a.m24 * b.m43;
            r.m24 = a.m21 * b.m14 + a.m22 * b.m24 + a.m23 * b.m34 + a.m24 * b.m44;

            r.m31 = a.m31 * b.m11 + a.m32 * b.m21 + a.m33 * b.m31 + a.m34 * b.m41;
            r.m32 = a.m31 * b.m12 + a.m32 * b.m22 + a.m33 * b.m32 + a.m34 * b.m42;
            r.m33 = a.m31 * b.m13 + a.m32 * b.m23 + a.m33 * b.m33 + a.m34 * b.m43;
            r.m34 = a.m31 * b.m14 + a.m32 * b.m24 + a.m33 * b.m34 + a.m34 * b.m44;

            r.m41 = a.m41 * b.m11 + a.m42 * b.m21 + a.m43 * b.m31 + a.m44 * b.m41;
            r.m42 = a.m41 * b.m12 + a.m42 * b.m22 + a.m43 * b.m32 + a.m44 * b.m42;
            r.m43 = a.m41 * b.m13 + a.m42 * b.m23 + a.m43 * b.m33 + a.m44 * b.m43;
            r.m44 = a.m41 * b.m14 + a.m42 * b.m24 + a.m43 * b.m34 + a.m44 * b.m44;

            return r;//コピーが発生するので、速度重視の場合は使わない
        }
Beispiel #28
0
        public void setMatrixTest()
        {
            LDMatrix44 matrix   = new LDMatrix44();
            LDMatrix44 actual   = new LDMatrix44();
            LDMatrix44 expected = new LDMatrix44();

            //ld_float delta = 0.00001f;
            ld_float[] m = new ld_float[16];

            // EMatrix44.setMatrix( const ld_float* _m ) のテスト
            for (int i = 0; i < 16; ++i)
            {
                m[i] = 1.0f;
            }
            actual.setMatrix(m);
            expected.m11 = 1.0f;
            expected.m12 = 1.0f;
            expected.m13 = 1.0f;
            expected.m14 = 1.0f;
            expected.m21 = 1.0f;
            expected.m22 = 1.0f;
            expected.m23 = 1.0f;
            expected.m24 = 1.0f;
            expected.m31 = 1.0f;
            expected.m32 = 1.0f;
            expected.m33 = 1.0f;
            expected.m34 = 1.0f;
            expected.m41 = 1.0f;
            expected.m42 = 1.0f;
            expected.m43 = 1.0f;
            expected.m44 = 1.0f;
            TestUtil.COMPARE(expected.m11, actual.m11);
            TestUtil.COMPARE(expected.m12, actual.m12);
            TestUtil.COMPARE(expected.m13, actual.m13);
            TestUtil.COMPARE(expected.m14, actual.m14);
            TestUtil.COMPARE(expected.m21, actual.m21);
            TestUtil.COMPARE(expected.m22, actual.m22);
            TestUtil.COMPARE(expected.m23, actual.m23);
            TestUtil.COMPARE(expected.m24, actual.m24);
            TestUtil.COMPARE(expected.m31, actual.m31);
            TestUtil.COMPARE(expected.m32, actual.m32);
            TestUtil.COMPARE(expected.m33, actual.m33);
            TestUtil.COMPARE(expected.m34, actual.m34);
            TestUtil.COMPARE(expected.m41, actual.m41);
            TestUtil.COMPARE(expected.m42, actual.m42);
            TestUtil.COMPARE(expected.m43, actual.m43);
            TestUtil.COMPARE(expected.m44, actual.m44);

            // EMatrix43.setMatrix( const EMatrix43 &m2 ) のテスト
            for (int i = 0; i < 16; ++i)
            {
                m[i] = 2.0f;
            }
            matrix.setMatrix(m);
            actual.setMatrix(matrix);
            expected.m11 = 2.0f;
            expected.m12 = 2.0f;
            expected.m13 = 2.0f;
            expected.m14 = 2.0f;
            expected.m21 = 2.0f;
            expected.m22 = 2.0f;
            expected.m23 = 2.0f;
            expected.m24 = 2.0f;
            expected.m31 = 2.0f;
            expected.m32 = 2.0f;
            expected.m33 = 2.0f;
            expected.m34 = 2.0f;
            expected.m41 = 2.0f;
            expected.m42 = 2.0f;
            expected.m43 = 2.0f;
            expected.m44 = 2.0f;
            TestUtil.COMPARE(expected.m11, actual.m11);
            TestUtil.COMPARE(expected.m12, actual.m12);
            TestUtil.COMPARE(expected.m13, actual.m13);
            TestUtil.COMPARE(expected.m14, actual.m14);
            TestUtil.COMPARE(expected.m21, actual.m21);
            TestUtil.COMPARE(expected.m22, actual.m22);
            TestUtil.COMPARE(expected.m23, actual.m23);
            TestUtil.COMPARE(expected.m24, actual.m24);
            TestUtil.COMPARE(expected.m31, actual.m31);
            TestUtil.COMPARE(expected.m32, actual.m32);
            TestUtil.COMPARE(expected.m33, actual.m33);
            TestUtil.COMPARE(expected.m34, actual.m34);
            TestUtil.COMPARE(expected.m41, actual.m41);
            TestUtil.COMPARE(expected.m42, actual.m42);
            TestUtil.COMPARE(expected.m43, actual.m43);
            TestUtil.COMPARE(expected.m44, actual.m44);
        }
Beispiel #29
0
        public void scaleTest()
        {
            LDMatrix44 expected = new LDMatrix44();
            LDMatrix44 actual = new LDMatrix44();
            //ld_float delta = 0.00001f;

            // Input : actual = 単位行列, x = 0.0, y = 0.0, z = 0.0 (ゼロ)
            expected.m11 = 0.0f;
            expected.m12 = 0.0f;
            expected.m13 = 0.0f;
            expected.m21 = 0.0f;
            expected.m22 = 0.0f;
            expected.m23 = 0.0f;
            expected.m31 = 0.0f;
            expected.m32 = 0.0f;
            expected.m33 = 0.0f;
            expected.m41 = 0.0f;
            expected.m42 = 0.0f;
            expected.m43 = 0.0f;
            actual.scale(0.0f, 0.0f, 0.0f);
            TestUtil.COMPARE(expected.m11, actual.m11);
            TestUtil.COMPARE(expected.m12, actual.m12);
            TestUtil.COMPARE(expected.m13, actual.m13);
            TestUtil.COMPARE(expected.m21, actual.m21);
            TestUtil.COMPARE(expected.m22, actual.m22);
            TestUtil.COMPARE(expected.m23, actual.m23);
            TestUtil.COMPARE(expected.m31, actual.m31);
            TestUtil.COMPARE(expected.m32, actual.m32);
            TestUtil.COMPARE(expected.m33, actual.m33);
            TestUtil.COMPARE(expected.m41, actual.m41);
            TestUtil.COMPARE(expected.m42, actual.m42);
            TestUtil.COMPARE(expected.m43, actual.m43);

            // Input : actual = 任意の値, x = 1.0, y = 2.0, z = 3.0 (任意の値)
            ld_float x = 1.0f;
            ld_float y = 2.0f;
            ld_float z = 3.0f;
            actual.m11 = 1.0f;
            actual.m12 = 2.0f;
            actual.m13 = 3.0f;
            actual.m21 = 1.0f;
            actual.m22 = 2.0f;
            actual.m23 = 3.0f;
            actual.m31 = 1.0f;
            actual.m32 = 2.0f;
            actual.m33 = 3.0f;
            actual.m41 = 1.0f;
            actual.m42 = 2.0f;
            actual.m43 = 3.0f;
            expected.m11 = actual.m11 * x;
            expected.m12 = actual.m12 * y;
            expected.m13 = actual.m13 * z;
            expected.m21 = actual.m21 * x;
            expected.m22 = actual.m22 * y;
            expected.m23 = actual.m23 * z;
            expected.m31 = actual.m31 * x;
            expected.m32 = actual.m32 * y;
            expected.m33 = actual.m33 * z;
            expected.m41 = actual.m41 * x;
            expected.m42 = actual.m42 * y;
            expected.m43 = actual.m43 * z;
            actual.scale(x, y, z);
            TestUtil.COMPARE(expected.m11, actual.m11);
            TestUtil.COMPARE(expected.m12, actual.m12);
            TestUtil.COMPARE(expected.m13, actual.m13);
            TestUtil.COMPARE(expected.m21, actual.m21);
            TestUtil.COMPARE(expected.m22, actual.m22);
            TestUtil.COMPARE(expected.m23, actual.m23);
            TestUtil.COMPARE(expected.m31, actual.m31);
            TestUtil.COMPARE(expected.m32, actual.m32);
            TestUtil.COMPARE(expected.m33, actual.m33);
            TestUtil.COMPARE(expected.m41, actual.m41);
            TestUtil.COMPARE(expected.m42, actual.m42);
            TestUtil.COMPARE(expected.m43, actual.m43);
        }
Beispiel #30
0
        /**
        * @brief 行列式
        * @param m EMatrix44をセットする
        * @return 行列式を返す
*/
        public ld_float det(LDMatrix44 m)
        {
            throw new NotImplementedException();
        }
Beispiel #31
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);
        }
Beispiel #32
0
        /**
        * @brief 逆行列
        * @param m EMatrix44をセットする
        * @return 逆行列を返す
*/
        public LDMatrix44 inverse(LDMatrix44 m)
        {
            throw new NotImplementedException();
        }
Beispiel #33
0
        public void translateTest()
        {
            LDMatrix44 expected = new LDMatrix44();
            LDMatrix44 actual = new LDMatrix44();
            //ld_float delta = 0.00001f;

            // Input : actual = 単位行列, x = 0.0, y = 0.0, z = 0.0 (ゼロ)
            actual.translate(0.0f, 0.0f, 0.0f);
            TestUtil.COMPARE(expected.m14, actual.m14);
            TestUtil.COMPARE(expected.m24, actual.m24);
            TestUtil.COMPARE(expected.m34, actual.m34);
            TestUtil.COMPARE(expected.m44, actual.m44);

            // Input : actual = 単位行列, x = 1.0, y = 2.0, z = 3.0 (任意の値)
            expected.m14 = 1.0f;
            expected.m24 = 2.0f;
            expected.m34 = 3.0f;
            expected.m44 = 1.0f;
            actual.translate(1.0f, 2.0f, 3.0f);
            TestUtil.COMPARE(expected.m14, actual.m14);
            TestUtil.COMPARE(expected.m24, actual.m24);
            TestUtil.COMPARE(expected.m34, actual.m34);
            TestUtil.COMPARE(expected.m44, actual.m44);

            // Input : actual = 任意の値, x = 1.0, y = 2.0, z = 3.0 (任意の値)
            ld_float x = 1.0f;
            ld_float y = 2.0f;
            ld_float z = 3.0f;
            actual.m11 = 1.0f;
            actual.m12 = 2.0f;
            actual.m13 = 3.0f;
            actual.m14 = 4.0f;
            actual.m21 = 1.0f;
            actual.m22 = 2.0f;
            actual.m23 = 3.0f;
            actual.m24 = 4.0f;
            actual.m31 = 1.0f;
            actual.m32 = 2.0f;
            actual.m33 = 3.0f;
            actual.m34 = 4.0f;
            actual.m41 = 1.0f;
            actual.m42 = 2.0f;
            actual.m43 = 3.0f;
            actual.m44 = 4.0f;
            expected.m14 = actual.m11 * x + actual.m12 * y + actual.m13 * z + actual.m14;
            expected.m24 = actual.m21 * x + actual.m22 * y + actual.m23 * z + actual.m24;
            expected.m34 = actual.m31 * x + actual.m32 * y + actual.m33 * z + actual.m34;
            expected.m44 = actual.m41 * x + actual.m42 * y + actual.m43 * z + actual.m44;
            actual.translate(x, y, z);
            TestUtil.COMPARE(expected.m14, actual.m14);
            TestUtil.COMPARE(expected.m24, actual.m24);
            TestUtil.COMPARE(expected.m34, actual.m34);
            TestUtil.COMPARE(expected.m44, actual.m44);
        }
Beispiel #34
0
        public void multTest()
        {
            LDMatrix44 matrix1  = new LDMatrix44();
            LDMatrix44 matrix2  = new LDMatrix44();
            LDMatrix44 expected = new LDMatrix44();
            LDMatrix44 actual   = new LDMatrix44();

            //ld_float delta = 0.00001f;

            // Input : matrix1 = 単位行列, matrix2 = 単位行列 (mult_fastのテスト)
            matrix1.mult(matrix2, actual);
            TestUtil.COMPARE(expected.m11, actual.m11);
            TestUtil.COMPARE(expected.m12, actual.m12);
            TestUtil.COMPARE(expected.m13, actual.m13);
            TestUtil.COMPARE(expected.m14, actual.m14);
            TestUtil.COMPARE(expected.m21, actual.m21);
            TestUtil.COMPARE(expected.m22, actual.m22);
            TestUtil.COMPARE(expected.m23, actual.m23);
            TestUtil.COMPARE(expected.m24, actual.m24);
            TestUtil.COMPARE(expected.m31, actual.m31);
            TestUtil.COMPARE(expected.m32, actual.m32);
            TestUtil.COMPARE(expected.m33, actual.m33);
            TestUtil.COMPARE(expected.m34, actual.m34);
            TestUtil.COMPARE(expected.m41, actual.m41);
            TestUtil.COMPARE(expected.m42, actual.m42);
            TestUtil.COMPARE(expected.m43, actual.m43);
            TestUtil.COMPARE(expected.m44, actual.m44);

            // Input : matrix1, matrix2 = 任意の値 (mult_fastのテスト)
            matrix1.m11   = 1.0f;
            matrix1.m12   = 2.0f;
            matrix1.m13   = 3.0f;
            matrix1.m14   = 4.0f;
            matrix1.m21   = 1.0f;
            matrix1.m22   = 2.0f;
            matrix1.m23   = 3.0f;
            matrix1.m24   = 4.0f;
            matrix1.m31   = 1.0f;
            matrix1.m32   = 2.0f;
            matrix1.m33   = 3.0f;
            matrix1.m34   = 4.0f;
            matrix1.m41   = 1.0f;
            matrix1.m42   = 2.0f;
            matrix1.m43   = 3.0f;
            matrix1.m44   = 4.0f;
            matrix2.m11   = 1.0f;
            matrix2.m12   = 2.0f;
            matrix2.m13   = 3.0f;
            matrix2.m14   = 4.0f;
            matrix2.m21   = 1.0f;
            matrix2.m22   = 2.0f;
            matrix2.m23   = 3.0f;
            matrix2.m24   = 4.0f;
            matrix2.m31   = 1.0f;
            matrix2.m32   = 2.0f;
            matrix2.m33   = 3.0f;
            matrix2.m34   = 4.0f;
            matrix2.m41   = 1.0f;
            matrix2.m42   = 2.0f;
            matrix2.m43   = 3.0f;
            matrix2.m44   = 4.0f;
            expected.m[0] = matrix1.m[0] * matrix2.m[0] + matrix1.m[4] * matrix2.m[1] +
                            matrix1.m[8] * matrix2.m[2] + matrix1.m[12] * matrix2.m[3];
            expected.m[1] = matrix1.m[1] * matrix2.m[0] + matrix1.m[5] * matrix2.m[1] +
                            matrix1.m[9] * matrix2.m[2] + matrix1.m[13] * matrix2.m[3];
            expected.m[2] = matrix1.m[2] * matrix2.m[0] + matrix1.m[6] * matrix2.m[1] +
                            matrix1.m[10] * matrix2.m[2] + matrix1.m[14] * matrix2.m[3];
            expected.m[3] = matrix1.m[3] * matrix2.m[0] + matrix1.m[7] * matrix2.m[1] +
                            matrix1.m[11] * matrix2.m[2] + matrix1.m[15] * matrix2.m[3];
            expected.m[4] = matrix1.m[0] * matrix2.m[4] + matrix1.m[4] * matrix2.m[5] +
                            matrix1.m[8] * matrix2.m[6] + matrix1.m[12] * matrix2.m[7];
            expected.m[5] = matrix1.m[1] * matrix2.m[4] + matrix1.m[5] * matrix2.m[5] +
                            matrix1.m[9] * matrix2.m[6] + matrix1.m[13] * matrix2.m[7];
            expected.m[6] = matrix1.m[2] * matrix2.m[4] + matrix1.m[6] * matrix2.m[5] +
                            matrix1.m[10] * matrix2.m[6] + matrix1.m[14] * matrix2.m[7];
            expected.m[7] = matrix1.m[3] * matrix2.m[4] + matrix1.m[7] * matrix2.m[5] +
                            matrix1.m[11] * matrix2.m[6] + matrix1.m[15] * matrix2.m[7];
            expected.m[8] = matrix1.m[0] * matrix2.m[8] + matrix1.m[4] * matrix2.m[9] +
                            matrix1.m[8] * matrix2.m[10] + matrix1.m[12] * matrix2.m[11];
            expected.m[9] = matrix1.m[1] * matrix2.m[8] + matrix1.m[5] * matrix2.m[9] +
                            matrix1.m[9] * matrix2.m[10] + matrix1.m[13] * matrix2.m[11];
            expected.m[10] = matrix1.m[2] * matrix2.m[8] + matrix1.m[6] * matrix2.m[9] +
                             matrix1.m[10] * matrix2.m[10] + matrix1.m[14] * matrix2.m[11];
            expected.m[11] = matrix1.m[3] * matrix2.m[8] + matrix1.m[7] * matrix2.m[9] +
                             matrix1.m[11] * matrix2.m[10] + matrix1.m[15] * matrix2.m[11];
            expected.m[12] = matrix1.m[0] * matrix2.m[12] + matrix1.m[4] * matrix2.m[13] +
                             matrix1.m[8] * matrix2.m[14] + matrix1.m[12] * matrix2.m[15];
            expected.m[13] = matrix1.m[1] * matrix2.m[12] + matrix1.m[5] * matrix2.m[13] +
                             matrix1.m[9] * matrix2.m[14] + matrix1.m[13] * matrix2.m[15];
            expected.m[14] = matrix1.m[2] * matrix2.m[12] + matrix1.m[6] * matrix2.m[13] +
                             matrix1.m[10] * matrix2.m[14] + matrix1.m[14] * matrix2.m[15];
            expected.m[15] = matrix1.m[3] * matrix2.m[12] + matrix1.m[7] * matrix2.m[13] +
                             matrix1.m[11] * matrix2.m[14] + matrix1.m[15] * matrix2.m[15];

            matrix1.mult(matrix2, actual);
            TestUtil.COMPARE(expected.m11, actual.m11);
            TestUtil.COMPARE(expected.m12, actual.m12);
            TestUtil.COMPARE(expected.m13, actual.m13);
            TestUtil.COMPARE(expected.m14, actual.m14);
            TestUtil.COMPARE(expected.m21, actual.m21);
            TestUtil.COMPARE(expected.m22, actual.m22);
            TestUtil.COMPARE(expected.m23, actual.m23);
            TestUtil.COMPARE(expected.m24, actual.m24);
            TestUtil.COMPARE(expected.m31, actual.m31);
            TestUtil.COMPARE(expected.m32, actual.m32);
            TestUtil.COMPARE(expected.m33, actual.m33);
            TestUtil.COMPARE(expected.m34, actual.m34);
            TestUtil.COMPARE(expected.m41, actual.m41);
            TestUtil.COMPARE(expected.m42, actual.m42);
            TestUtil.COMPARE(expected.m43, actual.m43);
            TestUtil.COMPARE(expected.m44, actual.m44);

            // Input : matrix1, matrix2 = 任意の値 (mult_safeのテスト) <- assertのため分岐できず
            //matrix1.mult(matrix2, &matrix1);
        }