예제 #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)));
        }
예제 #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));
        }
예제 #3
0
        // Quat-specific interpolation

        /// <summary>
        /// Performs a linear interpolation between two values, Alpha ranges from 0-1
        /// </summary>
        public static FQuat Lerp(FQuat a, FQuat b, float alpha)
        {
            return(FQuat.Slerp(a, b, alpha));
        }