Beispiel #1
0
        /// <summary>
        /// Interpolate quaternion from Current to Target. Scaled by angle to Target, so it has a strong start speed and ease out.
        /// </summary>
        public static FQuat QInterpTo(FQuat current, FQuat target, float deltaTime, float interpSpeed)
        {
            // If no interp speed, jump to target value
            if (interpSpeed <= 0.0f)
            {
                return(target);
            }

            // If the values are nearly equal, just return Target and assume we have reached our destination.
            if (current.Equals(target))
            {
                return(target);
            }

            return(FQuat.Slerp(current, target, FMath.Clamp(interpSpeed * deltaTime, 0.0f, 1.0f)));
        }
Beispiel #2
0
        /// <summary>
        /// Interpolate quaternion from Current to Target with constant step (in radians)
        /// </summary>
        public static FQuat QInterpConstantTo(FQuat current, FQuat target, float deltaTime, float interpSpeed)
        {
            // If no interp speed, jump to target value
            if (interpSpeed <= 0.0f)
            {
                return(target);
            }

            // If the values are nearly equal, just return Target and assume we have reached our destination.
            if (current.Equals(target))
            {
                return(target);
            }

            float deltaInterpSpeed = FMath.Clamp(deltaTime * interpSpeed, 0.0f, 1.0f);
            float angularDistance  = FMath.Max(SmallNumber, target.AngularDistance(current));
            float alpha            = FMath.Clamp(deltaInterpSpeed / angularDistance, 0.0f, 1.0f);

            return(FQuat.Slerp(current, target, alpha));
        }