Пример #1
0
        public void RotationMatrix()
        {
            using (var obj = new SKTransformNode()) {
                var zero = new MatrixFloat3x3();
                obj.RotationMatrix = zero;
                // In Swift, a rotated zero matrice also becomes the identity matrice.
                Asserts.AreEqual(MatrixFloat3x3.Identity, obj.RotationMatrix, "RotationMatrix");
                // Changing XRotation (or YRotation for that matter), makes the RotationMatrix change too
                obj.XRotation = (nfloat)(Math.PI / 2);
                var rotatedMatrix = new MatrixFloat3x3(
                    1, 0, 0,
                    0, 0, -1,
                    0, 1, 0
                    );
                Asserts.AreEqual(rotatedMatrix, obj.RotationMatrix, 0.000001f, "RotationMatrix a");
                Asserts.AreEqual(rotatedMatrix, CFunctions.GetMatrixFloat3x3(obj, "rotationMatrix"), 0.000001f, "RotationMatrix native a");

                // Got this matrix after setting both XRotation and YRotation to Pi/2
                rotatedMatrix = new MatrixFloat3x3(
                    0, 1, 0,
                    0, 0, -1,
                    -1, 0, 0
                    );
                obj.RotationMatrix = rotatedMatrix;
                Asserts.AreEqual(rotatedMatrix, obj.RotationMatrix, 0.000001f, "RotationMatrix b");
                Assert.AreEqual((nfloat)(Math.PI / 2), obj.XRotation, 0.000001f, "XRotation b");
                Assert.AreEqual(0, obj.YRotation, 0.000001f, "YRotation b");                  // Setting YRotation changes RotationMatrix, but setting RotationMatrix doesn't change YRotation.
            }
        }
Пример #2
0
        public void QuaternionTest()
        {
            Quaternion Q;

            using (var obj = new SKTransformNode()) {
                Asserts.AreEqual(Quaternion.Identity, obj.Quaternion, "1 Quaternion");
                Q = new Quaternion(new Vector3(1, 2, 3), 4);
                obj.Quaternion = Q;
                Asserts.AreEqual(Q, obj.Quaternion, "2 Quaternion");
            }
        }
Пример #3
0
        public void EulerAngles()
        {
            VectorFloat3 V3 = new VectorFloat3();

            using (var obj = new SKTransformNode()) {
                Asserts.AreEqual(V3, obj.EulerAngles, "1 EulerAngles");
                V3 = new VectorFloat3(1, 2, 3);
                obj.EulerAngles = V3;
                // The values bellow match what the same code in Swift returns.
                Assert.AreEqual(-2.14159298f, obj.EulerAngles.X, "#x1");
                Assert.AreEqual(1.14159274f, obj.EulerAngles.Y, "#y1");
                Assert.AreEqual(-0.141592711f, obj.EulerAngles.Z, "#z1");
            }
        }