Class Interpolation
Provides mathematical interpolation and easing functions for smooth animations, transitions, and motion. Includes spline interpolation (Cubic, Catmull-Rom), easing functions (smooth step variants), S-curve lerp overloads for float, UnityEngine.Vector2, and UnityEngine.Vector3, and frame-independent movement utilities.
Inherited Members
Namespace: Scylla.Core.Util
Assembly: ScyllaCore.dll
Syntax
public static class Interpolation
Remarks
For basic unclamped linear interpolation use Lerp(float, float, float).
The S-curve methods (LerpSmooth(float, float, float),
LerpSmoothEnd(float, float, float), LerpSmoothStart(float, float, float)) do
not clamp t; pass values in [0, 1] for well-defined S-curve behavior.
The MoveTowards(float, float, float, float) family is fully frame-rate independent when
deltaTime is supplied as Time.deltaTime, and will snap to the target exactly rather
than asymptotically approaching it.
Methods
CatmullRom(Vector3, Vector3, Vector3, Vector3, float)
Performs Catmull-Rom spline interpolation between four control points. The curve passes exactly
through p1 at t = 0 and p2 at t = 1, with
C1-continuous tangents derived from the surrounding control points. This makes it ideal for
constructing smooth paths through a sequence of waypoints by chaining adjacent four-point spans.
Declaration
public static Vector3 CatmullRom(Vector3 p0, Vector3 p1, Vector3 p2, Vector3 p3, float t)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | p0 | The control point before the active segment; determines the tangent entering |
| Vector3 | p1 | The start of the active segment; the curve passes through this point at |
| Vector3 | p2 | The end of the active segment; the curve passes through this point at |
| Vector3 | p3 | The control point after the active segment; determines the tangent leaving |
| float | t | The interpolation factor. Values outside [0, 1] extrapolate beyond the segment endpoints. |
Returns
| Type | Description |
|---|---|
| Vector3 | The interpolated UnityEngine.Vector3 position on the Catmull-Rom spline at parameter |
See Also
Cubic(Vector3, Vector3, Vector3, Vector3, float)
Performs cubic polynomial interpolation between four control points. The resulting curve passes
through y1 at t = 0 and y2 at t = 1, while
y0 and y3 act as tension-influencing outer control points.
Unlike Catmull-Rom, this cubic uses a simpler coefficient formula and does not guarantee C1
continuity across adjacent segments.
Declaration
public static Vector3 Cubic(Vector3 y0, Vector3 y1, Vector3 y2, Vector3 y3, float t)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | y0 | The control point before the curve segment; influences the slope at |
| Vector3 | y1 | The start of the curve segment; the curve passes through this point at |
| Vector3 | y2 | The end of the curve segment; the curve passes through this point at |
| Vector3 | y3 | The control point after the curve segment; influences the slope at |
| float | t | The interpolation factor. Values outside [0, 1] extrapolate beyond the segment endpoints. |
Returns
| Type | Description |
|---|---|
| Vector3 | The interpolated UnityEngine.Vector3 position on the cubic curve at parameter |
See Also
EaseInOutCubic(float, float, float, float)
Applies cubic ease-in-out interpolation using the classic Robert Penner easing API. The motion
starts slow (cubic ease-in), accelerates through the midpoint, and decelerates to a smooth stop
(cubic ease-out). This is the "slow start, fast middle, slow end" S-curve equivalent for a
duration-based (rather than normalized-t) animation interface.
Declaration
public static float EaseInOutCubic(float t, float b, float c, float d)
Parameters
| Type | Name | Description |
|---|---|---|
| float | t | The current elapsed time, in the same units as |
| float | b | The starting value at |
| float | c | The total change in value over the duration ( |
| float | d | The total duration. When |
Returns
| Type | Description |
|---|---|
| float | The eased value at time |
See Also
LerpExponential(float, float, float, float)
Interpolates between a and b using a power-curve easing
function. The blending factor is computed as t^n using exp(n * ln(t)). The shape
of the curve is fully controlled by the exponent:
n > 1- ease-in: slow start, accelerates towards the end.n = 1- linear: equivalent to a straight lerp.0 < n < 1- ease-out: fast start, decelerates towards the end.
When t is zero or negative, a is returned immediately
to avoid a logarithm of zero.
Declaration
public static float LerpExponential(float a, float b, float t, float n)
Parameters
| Type | Name | Description |
|---|---|---|
| float | a | The start value returned when |
| float | b | The end value returned when |
| float | t | The interpolation factor. Values at or below 0 return |
| float | n | The power exponent controlling the curve shape. Values greater than 1 produce ease-in; values between 0 and 1 produce ease-out. |
Returns
| Type | Description |
|---|---|
| float | The exponentially eased interpolated value. |
LerpSmooth(float, float, float)
Interpolates between a and b using a symmetric Hermite
S-curve. The blending factor is computed as 3t² - 2t³, which eases in at the start and
eases out at the end with equal acceleration and deceleration. Unlike SmoothStep(float),
t is not clamped - pass values in [0, 1] for standard S-curve behavior.
Declaration
public static float LerpSmooth(float a, float b, float t)
Parameters
| Type | Name | Description |
|---|---|---|
| float | a | The start value returned when |
| float | b | The end value returned when |
| float | t | The interpolation factor. Not clamped; values outside [0, 1] extrapolate. |
Returns
| Type | Description |
|---|---|
| float | The smoothly interpolated value between |
See Also
LerpSmooth(Vector2, Vector2, float)
Interpolates between two UnityEngine.Vector2 values using a symmetric Hermite S-curve.
The blending factor 3t² - 2t³ is applied uniformly to all components.
t is not clamped.
Declaration
public static Vector2 LerpSmooth(Vector2 a, Vector2 b, float t)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | a | The start UnityEngine.Vector2 returned when |
| Vector2 | b | The end UnityEngine.Vector2 returned when |
| float | t | The interpolation factor. Not clamped; values outside [0, 1] extrapolate. |
Returns
| Type | Description |
|---|---|
| Vector2 | The smoothly interpolated UnityEngine.Vector2 between |
See Also
LerpSmooth(Vector3, Vector3, float)
Interpolates between two UnityEngine.Vector3 values using a symmetric Hermite S-curve.
The blending factor 3t² - 2t³ is applied uniformly to all three components.
t is not clamped.
Declaration
public static Vector3 LerpSmooth(Vector3 a, Vector3 b, float t)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | a | The start UnityEngine.Vector3 returned when |
| Vector3 | b | The end UnityEngine.Vector3 returned when |
| float | t | The interpolation factor. Not clamped; values outside [0, 1] extrapolate. |
Returns
| Type | Description |
|---|---|
| Vector3 | The smoothly interpolated UnityEngine.Vector3 between |
See Also
LerpSmoothEnd(float, float, float)
Interpolates between a and b using an end-weighted S-curve.
The blending factor t + t² - t³ accelerates quickly near the start and decelerates
smoothly at the end (ease-out bias). Use this when motion should launch fast and settle gently.
t is not clamped.
Declaration
public static float LerpSmoothEnd(float a, float b, float t)
Parameters
| Type | Name | Description |
|---|---|---|
| float | a | The start value returned when |
| float | b | The end value returned when |
| float | t | The interpolation factor. Not clamped; values outside [0, 1] extrapolate. |
Returns
| Type | Description |
|---|---|
| float | The end-weighted smoothly interpolated value between |
See Also
LerpSmoothEnd(Vector2, Vector2, float)
Interpolates between two UnityEngine.Vector2 values using an end-weighted S-curve.
The blending factor t + t² - t³ is applied uniformly to all components, producing a
fast start and gentle deceleration at the end. t is not clamped.
Declaration
public static Vector2 LerpSmoothEnd(Vector2 a, Vector2 b, float t)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | a | The start UnityEngine.Vector2 returned when |
| Vector2 | b | The end UnityEngine.Vector2 returned when |
| float | t | The interpolation factor. Not clamped; values outside [0, 1] extrapolate. |
Returns
| Type | Description |
|---|---|
| Vector2 | The end-weighted smoothly interpolated UnityEngine.Vector2. |
See Also
LerpSmoothEnd(Vector3, Vector3, float)
Interpolates between two UnityEngine.Vector3 values using an end-weighted S-curve.
The blending factor t + t² - t³ is applied uniformly to all three components, producing
a fast start and gentle deceleration at the end. t is not clamped.
Declaration
public static Vector3 LerpSmoothEnd(Vector3 a, Vector3 b, float t)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | a | The start UnityEngine.Vector3 returned when |
| Vector3 | b | The end UnityEngine.Vector3 returned when |
| float | t | The interpolation factor. Not clamped; values outside [0, 1] extrapolate. |
Returns
| Type | Description |
|---|---|
| Vector3 | The end-weighted smoothly interpolated UnityEngine.Vector3. |
See Also
LerpSmoothStart(float, float, float)
Interpolates between a and b using a start-weighted S-curve.
The blending factor 1 - t - t² + t³ decelerates quickly near the end and eases in slowly
at the start (ease-in bias). Use this when motion should build speed gradually then stop sharply.
t is not clamped.
Declaration
public static float LerpSmoothStart(float a, float b, float t)
Parameters
| Type | Name | Description |
|---|---|---|
| float | a | The start value returned when |
| float | b | The end value returned when |
| float | t | The interpolation factor. Not clamped; values outside [0, 1] extrapolate. |
Returns
| Type | Description |
|---|---|
| float | The start-weighted smoothly interpolated value between |
See Also
LerpSmoothStart(Vector2, Vector2, float)
Interpolates between two UnityEngine.Vector2 values using a start-weighted S-curve.
The blending factor 1 - t - t² + t³ is applied uniformly to all components, producing a
slow ease-in and rapid deceleration near the end. t is not clamped.
Declaration
public static Vector2 LerpSmoothStart(Vector2 a, Vector2 b, float t)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | a | The start UnityEngine.Vector2 returned when |
| Vector2 | b | The end UnityEngine.Vector2 returned when |
| float | t | The interpolation factor. Not clamped; values outside [0, 1] extrapolate. |
Returns
| Type | Description |
|---|---|
| Vector2 | The start-weighted smoothly interpolated UnityEngine.Vector2. |
See Also
LerpSmoothStart(Vector3, Vector3, float)
Interpolates between two UnityEngine.Vector3 values using a start-weighted S-curve.
The blending factor 1 - t - t² + t³ is applied uniformly to all three components,
producing a slow ease-in and rapid deceleration near the end. t is not clamped.
Declaration
public static Vector3 LerpSmoothStart(Vector3 a, Vector3 b, float t)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | a | The start UnityEngine.Vector3 returned when |
| Vector3 | b | The end UnityEngine.Vector3 returned when |
| float | t | The interpolation factor. Not clamped; values outside [0, 1] extrapolate. |
Returns
| Type | Description |
|---|---|
| Vector3 | The start-weighted smoothly interpolated UnityEngine.Vector3. |
See Also
MoveTowards(float, float, float, float)
Moves current towards target at a constant speed,
advancing by at most speed * deltaTime per call. Unlike exponential approaches, this
method snaps exactly to target when the remaining distance is smaller than
the maximum step, so the value never overshoots. Passing Time.deltaTime as
deltaTime makes the movement fully frame-rate independent.
Declaration
public static float MoveTowards(float current, float target, float speed, float deltaTime)
Parameters
| Type | Name | Description |
|---|---|---|
| float | current | The current value to move from. |
| float | target | The target value to move towards. The result will never exceed this value. |
| float | speed | Maximum rate of change in units per second. Negative values move away from |
| float | deltaTime | Time elapsed since the last call, in seconds. Pass |
Returns
| Type | Description |
|---|---|
| float | The new value after advancing at most |
MoveTowards(Vector2, Vector2, float, float)
Moves current towards target in 2D space at a constant
speed, advancing by at most speed * deltaTime units along the straight-line vector
each call. The result snaps exactly to target when the remaining distance
is smaller than the maximum step or when the distance is below Epsilon.
Declaration
public static Vector2 MoveTowards(Vector2 current, Vector2 target, float speed, float deltaTime)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | current | The current UnityEngine.Vector2 position. |
| Vector2 | target | The target UnityEngine.Vector2 position. The result will never overshoot this point. |
| float | speed | Maximum speed in world units per second. |
| float | deltaTime | Time elapsed since the last call in seconds. Pass |
Returns
| Type | Description |
|---|---|
| Vector2 | The new UnityEngine.Vector2 position after advancing at most |
MoveTowards(Vector3, Vector3, float, float)
Moves current towards target in 3D space at a constant
speed, advancing by at most speed * deltaTime units along the straight-line vector
each call. The result snaps exactly to target when the remaining distance
is smaller than the maximum step or when the distance is below Epsilon.
Declaration
public static Vector3 MoveTowards(Vector3 current, Vector3 target, float speed, float deltaTime)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | current | The current UnityEngine.Vector3 position. |
| Vector3 | target | The target UnityEngine.Vector3 position. The result will never overshoot this point. |
| float | speed | Maximum speed in world units per second. |
| float | deltaTime | Time elapsed since the last call in seconds. Pass |
Returns
| Type | Description |
|---|---|
| Vector3 | The new UnityEngine.Vector3 position after advancing at most |
SmoothStep(float)
Applies smooth step interpolation to a normalized parameter, producing a Hermite S-curve.
The formula 3t² - 2t³ produces first-derivative continuity (zero tangent) at both
endpoints, making it suitable for blending effects, opacity fades, and interpolated movement
that must start and end without a velocity spike. The input is clamped to [0, 1] before evaluation.
Declaration
public static float SmoothStep(float t)
Parameters
| Type | Name | Description |
|---|---|---|
| float | t | The interpolation factor. Values outside [0, 1] are clamped before evaluation. |
Returns
| Type | Description |
|---|---|
| float | A smoothed value in [0, 1] following the Hermite curve |
See Also
SmootherStep(float)
Applies Ken Perlin's improved smooth step interpolation to a normalized parameter. The quintic
formula 6t⁵ - 15t⁴ + 10t³ has both zero first-derivative and zero second-derivative at
the endpoints, producing smoother transitions than SmoothStep(float). Perlin introduced
this variant to eliminate visual artifacts in improved Perlin noise; it is also useful anywhere
a higher-order fade is desired. The input is clamped to [0, 1] before evaluation.
Declaration
public static float SmootherStep(float t)
Parameters
| Type | Name | Description |
|---|---|---|
| float | t | The interpolation factor. Values outside [0, 1] are clamped before evaluation. |
Returns
| Type | Description |
|---|---|
| float | A smoothed value in [0, 1] following the quintic curve |