Example #1
0
        private void ComputeCameraRotation()
        {
            Vector3D lookVector = NormalizedLookVector;

            yawPitchRoll.Y = MathExtensions.Asin(-lookVector.Z);
            yawPitchRoll.X = -MathExtensions.Atan2(-lookVector.X, -lookVector.Y);
        }
Example #2
0
        public EulerAngles ToEuler()
        {
            float ww               = W * W;
            float xx               = X * X;
            float yy               = Y * Y;
            float zz               = Z * Z;
            float lengthSqd        = xx + yy + zz + ww;
            float singularityTest  = Y * W - X * Z;
            float singularityValue = Singularity * lengthSqd;

            return(singularityTest > singularityValue
                                ? new EulerAngles(-2 * MathExtensions.Atan2(Z, W), 90.0f, 0.0f)
                                : singularityTest < -singularityValue
                                        ? new EulerAngles(2 * MathExtensions.Atan2(Z, W), -90.0f, 0.0f)
                                        : new EulerAngles(MathExtensions.Atan2(2.0f * (Y * Z + X * W), 1.0f - 2.0f * (xx + yy)),
                                                          MathExtensions.Asin(2.0f * singularityTest / lengthSqd),
                                                          MathExtensions.Atan2(2.0f * (X * Y + Z * W), 1.0f - 2.0f * (yy + zz))));
        }
Example #3
0
 public void Asin()
 {
     Assert.AreEqual(0.0f, MathExtensions.Asin(0));
     Assert.AreEqual(90.0f, MathExtensions.Asin(1));
     Assert.AreEqual(-90.0f, MathExtensions.Asin(-1));
 }