/// - We allow reduction if the reduced magnitude doesn't go off very far
        /// - And the angle between the two rotations is similar
        bool QuaternionDistanceError(Quaternion value, Quaternion reduced, float quaternionDotError)
        {
            float magnitude = QUtil.Magnitude(reduced);

            if (Mathf.Abs(1.0F - magnitude) > kQuaternionNormalizationError)
            {
                return(false);
            }

            value = QUtil.Normalize(value);

            reduced.x /= magnitude;
            reduced.y /= magnitude;
            reduced.z /= magnitude;
            reduced.w /= magnitude;

            // float angle = Rad2Deg(acos (Dot(value, reduced))) * 2.0F;
            // if (dot > kQuaternionAngleError)
            //        return false;
            if (Quaternion.Dot(value, reduced) < quaternionDotError)
            {
                return(false);
            }

            return(true);
        }
Esempio n. 2
0
        private Quaternion _BakeQ(AnimationCurve xCurve, AnimationCurve yCurve, AnimationCurve zCurve, AnimationCurve wCurve, float t)
        {
            float x = xCurve.Evaluate(t);
            float y = yCurve.Evaluate(t);
            float z = zCurve.Evaluate(t);
            float w = wCurve.Evaluate(t);

            Quaternion q = new Quaternion(x, y, z, w);

            return(QUtil.Normalize(q));
        }