Exemplo n.º 1
0
 public void rotate(ld_float theta)
 {
     m_matrix.rotateZ(theta);
 }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
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);
        }