コード例 #1
0
ファイル: LDMatrix44Test.cs プロジェクト: johndpope/math
        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);
        }
コード例 #2
0
ファイル: LDMatrix44Test.cs プロジェクト: KajitaLD/math
        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);
        }
コード例 #3
0
ファイル: LDAffineTransform.cs プロジェクト: johndpope/math
 public void translate(ld_float x, ld_float y)
 {
     m_matrix.translate(x, y, 0);
 }