Exemplo n.º 1
0
        public void normalizeTest()
        {
            LDQuat actual   = new LDQuat();
            LDQuat expected = new LDQuat();
            //ld_float delta = 0.00001f;
            ld_float oneOverMag;

            // Input : vector{x = 0.0, y = 0.0, z = 0.0, w = 1.0} (単位クォータニオン)
            actual.x   = 0.0f;
            actual.y   = 0.0f;
            actual.z   = 0.0f;
            actual.w   = 1.0f;
            expected.x = 0.0f;
            expected.y = 0.0f;
            expected.z = 0.0f;
            expected.w = 1.0f;
            actual.normalize();
            TestUtil.COMPARE(expected.x, actual.x);
            TestUtil.COMPARE(expected.y, actual.y);
            TestUtil.COMPARE(expected.z, actual.z);
            TestUtil.COMPARE(expected.w, actual.w);

            // Input : vector{x = 1.0, y = 2.0, z = 3.0, w = 4.0} (任意の値)
            actual.x   = 1.0f;
            actual.y   = 2.0f;
            actual.z   = 3.0f;
            actual.w   = 4.0f;
            oneOverMag = 1.0f / (ld_float)(float)Math.Sqrt(actual.w * actual.w + actual.x * actual.x
                                                           + actual.y * actual.y + actual.z * actual.z);
            expected.x = 1.0f * oneOverMag;
            expected.y = 2.0f * oneOverMag;
            expected.z = 3.0f * oneOverMag;
            expected.w = 4.0f * oneOverMag;
            actual.normalize();
            TestUtil.COMPARE(expected.x, actual.x);
            TestUtil.COMPARE(expected.y, actual.y);
            TestUtil.COMPARE(expected.z, actual.z);
            TestUtil.COMPARE(expected.w, actual.w);
        }
Exemplo n.º 2
0
        public void normalizeTest()
        {
            LDQuat actual = new LDQuat();
            LDQuat expected = new LDQuat();
            //ld_float delta = 0.00001f;
            ld_float oneOverMag;

            // Input : vector{x = 0.0, y = 0.0, z = 0.0, w = 1.0} (単位クォータニオン)
            actual.x = 0.0f;
            actual.y = 0.0f;
            actual.z = 0.0f;
            actual.w = 1.0f;
            expected.x = 0.0f;
            expected.y = 0.0f;
            expected.z = 0.0f;
            expected.w = 1.0f;
            actual.normalize();
            TestUtil.COMPARE(expected.x, actual.x);
            TestUtil.COMPARE(expected.y, actual.y);
            TestUtil.COMPARE(expected.z, actual.z);
            TestUtil.COMPARE(expected.w, actual.w);

            // Input : vector{x = 1.0, y = 2.0, z = 3.0, w = 4.0} (任意の値)
            actual.x = 1.0f;
            actual.y = 2.0f;
            actual.z = 3.0f;
            actual.w = 4.0f;
            oneOverMag = 1.0f / (ld_float)(float)Math.Sqrt(actual.w * actual.w + actual.x * actual.x
                                                  + actual.y * actual.y + actual.z * actual.z);
            expected.x = 1.0f * oneOverMag;
            expected.y = 2.0f * oneOverMag;
            expected.z = 3.0f * oneOverMag;
            expected.w = 4.0f * oneOverMag;
            actual.normalize();
            TestUtil.COMPARE(expected.x, actual.x);
            TestUtil.COMPARE(expected.y, actual.y);
            TestUtil.COMPARE(expected.z, actual.z);
            TestUtil.COMPARE(expected.w, actual.w);
        }