Пример #1
0
        public void setToRotateAxis(LDVector3 axis, ld_float theta)
        {
            Debug.Assert(Math.Abs(axis.length() - 1.0f) < 0.01f);

            ld_float theta_over2 = theta * 0.5f;
            ld_float sinQ_over2  = (ld_float)Math.Sin(theta_over2);

            w = (ld_float)Math.Cos(theta_over2);
            x = axis.x * sinQ_over2;
            y = axis.y * sinQ_over2;
            z = axis.z * sinQ_over2;
        }
Пример #2
0
        public void lengthTest()
        {
            LDVector3 vector = new LDVector3();
            ld_float  actual;
            ld_float  expected;

            //ld_float delta = 0.00001f;

            // Input : x = 0.0, y = 0.0, z = 0.0 (ゼロベクトル)
            vector.zero();
            expected = 0.0f;
            actual   = vector.length();
            TestUtil.COMPARE(expected, actual);

            // Input : x = 1.0, y = 2.0, z = 3.0 (任意の値)
            vector.x = 1.0f;
            vector.y = 2.0f;
            vector.z = 3.0f;
            expected = (ld_float)Math.Sqrt(vector.x * vector.x + vector.y * vector.y + vector.z * vector.z);
            actual   = vector.length();
            TestUtil.COMPARE(expected, actual);

            // 非メンバ関数lengthのテスト

            // Input : x = 0.0, y = 0.0, z = 0.0 (ゼロベクトル)
            vector.zero();
            expected = 0.0f;
            actual   = LDVector3.length(vector);
            TestUtil.COMPARE(expected, actual);

            // Input : x = 1.0, y = 2.0, z = 3.0 (任意の値)
            vector.x = 1.0f;
            vector.y = 2.0f;
            vector.z = 3.0f;
            expected = (ld_float)Math.Sqrt(vector.x * vector.x + vector.y * vector.y + vector.z * vector.z);
            actual   = LDVector3.length(vector);
            TestUtil.COMPARE(expected, actual);
        }
Пример #3
0
        public void setToRotateAxis(LDVector3 axis, ld_float theta)
        {
            Debug.Assert(Math.Abs(axis.length() - 1.0f) < 0.01f);

            ld_float theta_over2 = theta * 0.5f;
            ld_float sinQ_over2 = (ld_float)Math.Sin(theta_over2);

            w = (ld_float)Math.Cos(theta_over2);
            x = axis.x * sinQ_over2;
            y = axis.y * sinQ_over2;
            z = axis.z * sinQ_over2;
        }
Пример #4
0
        public void lengthTest()
        {
            LDVector3 vector = new LDVector3();
            ld_float actual;
            ld_float expected;
            //ld_float delta = 0.00001f;

            // Input : x = 0.0, y = 0.0, z = 0.0 (ゼロベクトル)
            vector.zero();
            expected = 0.0f;
            actual = vector.length();
            TestUtil.COMPARE(expected, actual);

            // Input : x = 1.0, y = 2.0, z = 3.0 (任意の値)
            vector.x = 1.0f;
            vector.y = 2.0f;
            vector.z = 3.0f;
            expected = (ld_float)Math.Sqrt(vector.x * vector.x + vector.y * vector.y + vector.z * vector.z);
            actual = vector.length();
            TestUtil.COMPARE(expected, actual);

            // 非メンバ関数lengthのテスト

            // Input : x = 0.0, y = 0.0, z = 0.0 (ゼロベクトル)
            vector.zero();
            expected = 0.0f;
            actual = LDVector3.length(vector);
            TestUtil.COMPARE(expected, actual);

            // Input : x = 1.0, y = 2.0, z = 3.0 (任意の値)
            vector.x = 1.0f;
            vector.y = 2.0f;
            vector.z = 3.0f;
            expected = (ld_float)Math.Sqrt(vector.x * vector.x + vector.y * vector.y + vector.z * vector.z);
            actual = LDVector3.length(vector);
            TestUtil.COMPARE(expected, actual);
        }