Skip to main content

lerp_angle

Function lerp_angle 

Source
pub fn lerp_angle(a: f32, b: f32, t: f32) -> f32
Expand description

Shortest-arc interpolation between two angles in radians, for packed ValueKind::Angle filter params.

Filter-owned on purpose (not a crate::animations::Lerp impl): the style rotate transition deliberately animates its angle as a bare scalar (720° → 0° unwinds through two full turns), so shortest-arc must not leak into the general lerp primitives. Packed angle params feed periodic shader math (hue rotation), where only the angle mod 2π matters and the short way around the circle is the right path.

t == 0.0 returns a and t == 1.0 returns b bit-exactly (the t == 1.0 branch is load-bearing: the wrapped formula would land on b’s angle only mod 2π). In between the result is a + wrap(b - a) * t, with wrap folding the difference into (-π, π] — so for t ∈ (0, 1) the result lands within π of a, is NOT normalized to any canonical range, and is consumed directly as radians. Exactly-opposite angles take the positive (counter-clockwise) arc. t outside 0..=1 extrapolates along the same arc.