private void ComputeCameraRotation() { Vector3D lookVector = NormalizedLookVector; yawPitchRoll.Y = MathExtensions.Asin(-lookVector.Z); yawPitchRoll.X = -MathExtensions.Atan2(-lookVector.X, -lookVector.Y); }
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)))); }
public void Asin() { Assert.AreEqual(0.0f, MathExtensions.Asin(0)); Assert.AreEqual(90.0f, MathExtensions.Asin(1)); Assert.AreEqual(-90.0f, MathExtensions.Asin(-1)); }