Navigation
API > API/Runtime > API/Runtime/Core
Collection of useful spring methods which can be used for damping, simulating characters etc.
Reference https://theorangeduck.com/page/spring-roll-callhttps://theorangeduck.com/page/scalar-velocityhttps://theorangeduck.com/page/dead-blendinghttps://theorangeduck.com/page/propagating-velocities-through-animation-systemshttps://theorangeduck.com/page/fitting-code-driven-displacementhttps://theorangeduck.com/page/fitting-code-driven-displacement-revisited
| Name | SpringMath |
| Type | struct |
| Header File | /Engine/Source/Runtime/Core/Public/Math/SpringMath.h |
| Include Path | #include "Math/SpringMath.h" |
Syntax
struct SpringMath
Functions
Static
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
static float AngleGetShortestArcWith
(
float A, |
Gets the version of angle A which is closest to reference angle B | Math/SpringMath.h | |
static void CriticalDecay
(
T& InOutX, |
Simplified version of CriticalSpringDamper where the target is assumed to be 0. | Math/SpringMath.h | |
static void CriticalDecayAngle
(
float& InOutAngleRadians, |
Specialized angle version of CriticalDecay that handles angle wrapping. | Math/SpringMath.h | |
static void CriticalDecayQuat
(
FQuat& InOutRotation, |
Specialized quaternion version of CriticalDecay, uses FVector for angular velocity | Math/SpringMath.h | |
static void CriticalDecayScale
(
FVector& InOutScale, |
Specialized scale version of CriticalDecay | Math/SpringMath.h | |
static void CriticalDoubleSpringDamper
(
T& InOutX, |
A double spring damper that interpolates the value InOutX towards TargetX via some intermediate state - producing a more S-shaped curve. | Math/SpringMath.h | |
static void CriticalDoubleSpringDamperAngle
(
float& InOutAngleRadians, |
Specialized angle version of CriticalDoubleSpringDamper that handles angle wrapping. | Math/SpringMath.h | |
static void CriticalDoubleSpringDamperQuat
(
FQuat& InOutRotation, |
Specialized quaternion version of CriticalDoubleSpringDamper, uses FVector for angular velocity | Math/SpringMath.h | |
static void CriticalDoubleSpringDamperScale
(
FVector& InOutScale, |
Specialized scale version of CriticalDoubleSpringDamper | Math/SpringMath.h | |
static void CriticalSpringDamper
(
T& InOutX, |
Simplified version of FMath::CriticallyDampedSmoothing where v_goal is assumed to be 0. | Math/SpringMath.h | |
static void CriticalSpringDamperAngle
(
float& InOutAngleRadians, |
Specialized angle version of CriticalSpringDamper that handles angle wrapping. | Math/SpringMath.h | |
static void CriticalSpringDamperQuat
(
FQuat& InOutRotation, |
Specialized quaternion version of CriticalSpringDamper, uses FVector for angular velocity | Math/SpringMath.h | |
static void CriticalSpringDamperQuatPredict
(
TArrayView< FQuat > OutPredictedRotations, |
Prediction of CriticalSpringDamperQuat | Math/SpringMath.h | |
static void CriticalSpringDamperScale
(
FVector& InOutScale, |
Specialized scale version of CriticalSpringDamper, uses FVector for scalar velocity | Math/SpringMath.h | |
static void CubicDecayWeights
(
float& OutW0, |
Compute the cubic weights required to inertialize out an offset and velocity offset for a given time and blend time | Math/SpringMath.h | |
static void CubicInertializeApply
(
TValue& InOutValue, |
Applies a cubic inertialization to the input value (and velocity), updating them in place by adding the appropriate offset given the time since transition. | Math/SpringMath.h | |
static void CubicInertializeApplyAngle
(
float& InOutAngle, |
Specialization of CubicInertializeApply for angles. Stores velocities in rad/s. | Math/SpringMath.h | |
static void CubicInertializeApplyQuat
(
FQuat& InOutRotation, |
Specialization of CubicInertializeApply for quaternions. Stores velocities in rad/s. | Math/SpringMath.h | |
static void CubicInertializeApplyScale
(
FVector& InOutScale, |
Specialization of CubicInertializeApply for scales. | Math/SpringMath.h | |
static void CubicInertializeTransition
(
TValue& InOutValueOffset, |
Transitions a cubic inertialization, computing a new offset value. | Math/SpringMath.h | |
static void CubicInertializeTransitionAngle
(
float& InOutAngleOffset, |
Specialization of CubicInertializeTransition for angles. Stores velocities in rad/s. | Math/SpringMath.h | |
static void CubicInertializeTransitionQuat
(
FQuat& InOutRotationOffset, |
Specialization of CubicInertializeTransition for quaternions. Stores velocities in rad/s. | Math/SpringMath.h | |
static void CubicInertializeTransitionScale
(
FVector& InOutScaleOffset, |
Specialization of CubicInertializeTransition for scales. | Math/SpringMath.h | |
static float DampingToSmoothingTime
(
float Damping |
Math/SpringMath.h | ||
static void DeadBlendApply
(
TValue& InOutValue, |
Applies a dead blend to the input value (and velocity), updating them in place by blending them with an extrapolation of the value and velocity at the point of the last transition. | Math/SpringMath.h | |
static void DeadBlendApplyAngle
(
float& InOutValue, |
Specialization of DeadBlendApply for angles. Stores velocities in rad/s. | Math/SpringMath.h | |
static void DeadBlendApplyQuat
(
FQuat& InOutValue, |
Specialization of DeadBlendApply for quaternions. Stores velocities in rad/s. | Math/SpringMath.h | |
static void DeadBlendApplyScale
(
FVector& InOutValue, |
Specialization of DeadBlendApply for scales. | Math/SpringMath.h | |
static void DeadBlendExtrapolate
(
TValue& InOutValue, |
Extrapolates a value and velocity in place assuming some decay rate on the velocity. | Math/SpringMath.h | |
static void DeadBlendExtrapolateQuat
(
FQuat& InOutValue, |
Specialization of DeadBlendExtrapolate for quaternions. Angular velocities are stored in rad/s. | Math/SpringMath.h | |
static void DeadBlendExtrapolateScale
(
FVector& InOutValue, |
Specialization of DeadBlendExtrapolate for scales. | Math/SpringMath.h | |
static void DeadBlendTransition
(
TValue& InOutValueTransition, |
Transitions a dead blend, computing the new value and velocity at the point of transition. | Math/SpringMath.h | |
static void DeadBlendTransitionAngle
(
float& InOutValueTransition, |
Specialization of DeadBlendTransition for angles. Stores velocities in rad/s. | Math/SpringMath.h | |
static void DeadBlendTransitionQuat
(
FQuat& InOutValueTransition, |
Specialization of DeadBlendTransition for quaternions. Stores velocities in rad/s. | Math/SpringMath.h | |
static void DeadBlendTransitionScale
(
FVector& InOutValueTransition, |
Specialization of DeadBlendTransition for scales. | Math/SpringMath.h | |
static void ExponentialSmoothingApproxAngle
(
float& InOutAngleRadians, |
Specialized angle damper, similar to FMath::ExponentialSmoothingApprox but deals correctly with angle wrap-around. | Math/SpringMath.h | |
static void ExponentialSmoothingApproxQuat
(
FQuat& InOutRotation, |
Specialized quaternion damper, similar to FMath::ExponentialSmoothingApprox but for quaternions. | Math/SpringMath.h | |
static void ExponentialSmoothingApproxScale
(
FVector& InOutScale, |
Specialized scale damper, similar to FMath::ExponentialSmoothingApprox but for scales. | Math/SpringMath.h | |
static float HalfLifeToSmoothingTime
(
float HalfLife |
Convert a halflife to a smoothing time | Math/SpringMath.h | |
static float LambertWLower
(
const float X |
Computes the lower (-1) branch of the LambertW function, which is used for solving equations of the form x*e^x - input will be clamped to range [-1/e, 0], output will be in range [-1, -inf] | Math/SpringMath.h | |
static FVector ScaleDivMax
(
FVector Lhs, |
Divides one scale by another, clamping the Rhs to be greater than some minimum | Math/SpringMath.h | |
static FVector ScaleEerp
(
FVector A, |
Performs an Eerp on scales (interpolation in the multiplicative space) | Math/SpringMath.h | |
static FVector ScaleExp
(
FVector V, |
Computes the exponent of a scale, ensuring the value is not too large to prevent it exploding | Math/SpringMath.h | |
static FVector ScaleLog
(
FVector V |
Takes the log of a scale, clamping the scale to ensure it is greater than zero | Math/SpringMath.h | |
static float SmoothingTimeToDamping
(
float SmoothingTime |
Math/SpringMath.h | ||
static float SmoothingTimeToHalfLife
(
float SmoothingTime |
Convert a smoothing time to a half life | Math/SpringMath.h | |
static float SmoothingTimeToStrength
(
float SmoothingTime |
Convert from smoothing time to spring strength. | Math/SpringMath.h | |
static float SpringCharacterMaximumAcceleration
(
const float InitialVelocity, |
Estimates the maximum acceleration for a character | Math/SpringMath.h | |
static TOptional< float > SpringCharacterMaximumAccelerationTime
(
const float InitialVelocity, |
Estimates the time at which the maximum acceleration will occur. | Math/SpringMath.h | |
static float SpringCharacterMaximumAngularVelocity
(
const float InitialAngle, |
Estimates the maximum angular velocity for a character | Math/SpringMath.h | |
static TOptional< float > SpringCharacterMaximumAngularVelocityTime
(
const float InitialAngle, |
Estimates the time in the future at which the maximum angular velocity will occur. | Math/SpringMath.h | |
static void SpringCharacterPredict
(
TArrayView< TVector > OutPredictedPositions, |
Gives predicted positions, velocities and accelerations for SpringCharacterUpdate. | Math/SpringMath.h | |
static float SpringCharacterSmoothingTimeFromMaximumAcceleration
(
const float InitialVelocity, |
Estimates an approximate spring smoothing time from the maximum acceleration | Math/SpringMath.h | |
static float SpringCharacterSmoothingTimeFromMaximumAngularVelocity
(
const float InitialAngle, |
Estimates an approximate spring smoothing time from the maximum angular velocity | Math/SpringMath.h | |
static float SpringCharacterSmoothingTimeFromStartingDistance
(
const float TargetVelocity, |
Estimates an approximate spring smoothing time from a starting distance and target velocity for a character using a simple damped spring. | Math/SpringMath.h | |
static float SpringCharacterSmoothingTimeFromStartingTime
(
const float TargetVelocity, |
Estimates an approximate spring smoothing time from a starting time and target velocity for a character using a simple damped spring. | Math/SpringMath.h | |
static float SpringCharacterSmoothingTimeFromStoppingDistance
(
const float InitialVelocity, |
Estimates an approximate spring smoothing time from a stopping distance and velocity for a character using a simple damped spring. | Math/SpringMath.h | |
static float SpringCharacterSmoothingTimeFromStoppingTime
(
const float InitialVelocity, |
Estimates an approximate spring smoothing time from a stopping time and velocity for a character using a simple damped spring. | Math/SpringMath.h | |
static float SpringCharacterStartingDistance
(
const float TargetVelocity, |
Estimates an approximate starting distance (the distance traveled until the velocity gets within the VelocityThreshold of the TargetVelocity) from a smoothing time for a character using a simple damped spring | Math/SpringMath.h | |
static float SpringCharacterStartingTime
(
const float TargetVelocity, |
Estimates an approximate starting time (the time at which the velocity gets within the VelocityThreshold of the TargetVelocity) from a smoothing time and target velocity for a character using a simple damped spring | Math/SpringMath.h | |
static float SpringCharacterStoppingDistance
(
const float InitialVelocity, |
Estimates an approximate stopping distance from a smoothing time for a character using a simple damped spring | Math/SpringMath.h | |
static TOptional< float > SpringCharacterStoppingInflectionTime
(
const float InitialVelocity, |
Estimates the time in the future at which a character driven by a critical spring will reach zero acceleration. | Math/SpringMath.h | |
static float SpringCharacterStoppingTime
(
const float InitialVelocity, |
Estimates an approximate stopping time (the time at which the velocity goes below the VelocityThreshold) from a smoothing time and velocity for a character using a simple damped spring | Math/SpringMath.h | |
static void SpringCharacterUpdate
(
TVector& InOutPosition, |
Update the position of a character given a target velocity using a simple damped spring | Math/SpringMath.h | |
static void SpringInertializeApply
(
TValue& InOutValue, |
Applies a spring inertialization to the input value (and velocity), updating them in place by adding the appropriate offset given the time since transition. | Math/SpringMath.h | |
static void SpringInertializeApplyAngle
(
float& InOutAngle, |
Specialization of SpringInertializeApply for angles. Stores velocities in rad/s. | Math/SpringMath.h | |
static void SpringInertializeApplyQuat
(
FQuat& InOutRotation, |
Specialization of SpringInertializeApply for quaternions. Stores velocities in rad/s. | Math/SpringMath.h | |
static void SpringInertializeApplyScale
(
FVector& InOutScale, |
Specialization of SpringInertializeApply for scales. | Math/SpringMath.h | |
static void SpringInertializeTransition
(
TValue& InOutValueOffset, |
Transitions a spring inertialization, computing a new offset value. | Math/SpringMath.h | |
static void SpringInertializeTransitionAngle
(
float& InOutAngleOffset, |
Specialization of SpringInertializeTransition for angles. Stores velocities in rad/s. | Math/SpringMath.h | |
static void SpringInertializeTransitionQuat
(
FQuat& InOutRotationOffset, |
Specialization of SpringInertializeTransition for quaternions. Stores velocities in rad/s. | Math/SpringMath.h | |
static void SpringInertializeTransitionScale
(
FVector& InOutScaleOffset, |
Specialization of SpringInertializeTransition for Scales | Math/SpringMath.h | |
static float StrengthToSmoothingTime
(
float Strength |
Convert from spring strength to smoothing time. | Math/SpringMath.h | |
static void TrackVelocity
(
TValue& InOutValue, |
Tracks the velocity of the input value InValue via finite difference, updating InOutValue and InOutVelocity in place. | Math/SpringMath.h | |
static void TrackVelocityAngle
(
float& InOutValue, |
Tracks the velocity of the input angle InValue via finite difference, updating InOutValue and InOutVelocity in place. | Math/SpringMath.h | |
static void TrackVelocityQuat
(
FQuat& InOutValue, |
Tracks the velocity of the input rotation InValue via finite difference, updating InOutValue and InOutVelocity in place. | Math/SpringMath.h | |
static void TrackVelocityScale
(
FVector& InOutValue, |
Tracks the velocity of the input scale InValue via finite difference, updating InOutValue and InOutVelocity in place. | Math/SpringMath.h | |
static void VelocitySpringCharacterPredict
(
TArrayView< TVector > OutPredictedPositions, |
Gives predicted positions, velocities and accelerations for SpringCharacterUpdate. | Math/SpringMath.h | |
static void VelocitySpringCharacterUpdate
(
TVector& InOutPosition, |
Update a position representing a character given a target velocity using a velocity spring. | Math/SpringMath.h | |
static void VelocitySpringDamper
(
TVector& InOutX, |
A velocity spring will damp towards a target that follows a fixed linear target velocity, allowing control of the interpolation speed while still giving a smoothed behaviour. | Math/SpringMath.h | |
static void VelocitySpringDamperF
(
TFloat& InOutX, |
A velocity spring will damp towards a target that follows a fixed linear target velocity, allowing control of the interpolation speed while still giving a smoothed behavior. | Math/SpringMath.h |