// TODO: untested public Quaternion Interpolate(Quaternion to, float dt) { Float4 v0 = ToFloat4(); Float4 v1 = to.ToFloat4(); float dot = v0.Dot(v1); if (dot < 0.0f) { v1 = new Float4(-v1.X, -v1.Y, -v1.Z, -v1.W); dot = -dot; } if (dot > 0.9995f) { return(to); //// If the inputs are too close for comfort, linearly interpolate and normalize the result //Float4 result = v0 + dt * (v1 - v0); //result.Normalize(); //return new Quaternion(result); } float theta = RyneMath.Acos(dot); float deltaTheta = theta * dt; float sinTheta = RyneMath.Sin(theta); float sinDeltaTheta = RyneMath.Sin(deltaTheta); float s0 = RyneMath.Cos(deltaTheta) - dot * sinDeltaTheta / sinTheta; float s1 = sinDeltaTheta / sinTheta; return(new Quaternion((s0 * v0) + (s1 * v1))); }
public float RotationAngle(bool degrees = true) { return(RyneMath.RadiansToDegrees(2.0f * RyneMath.Acos(W))); }