Interpolation on Manifolds

SkillProductivity

Abstract math for interpolating angles, vectors, and quaternions on curved manifolds. USE FOR: implementing Lerp (linear interpolation) for vectors; Nlerp (normalized lerp) for directions; Slerp (spherical linear interpolation) for quaternions and unit vectors; shortest-path sign flip when dot product is negative; choosing between Lerp/Nlerp/Slerp; angular lerp with wrap-around. DO NOT USE FOR: quaternion arithmetic (use quaternion-algebra); rotation representation conversions (use 3d-rotation-theory); angle unit conversions (use angles-and-circular-arithmetic).

Available today. Use it from your connected AI after setup.

Connect ahel once, and every AI you use reads what you have installed.

Then ask your AI: use the Interpolation on Manifolds skill

What this skill tells your AI

The instructions your AI receives, as published by netfabric/netfabric.numerics in .agents/skills/interpolation-on-manifolds/SKILL.md and read by ahel’s review.

Lerp (Linear Interpolation)

lerp(a, b, t) = (1−t)·a + t·b Result NOT on unit sphere; constant Euclidean velocity.

Nlerp (Normalized Lerp)

nlerp(a, b, t) = normalize(lerp(a, b, t)) Cheaper than Slerp; breaks down at antipodal inputs.

Slerp (Spherical Linear Interpolation)

Great-circle arc at constant angular velocity:

Ω = arccos(a · b)
slerp(a, b, t) = sin((1−t)Ω)/sin(Ω) · a  +  sin(tΩ)/sin(Ω) · b

Fall back to Lerp when Ω ≈ 0. Undefined for antipodal inputs (Ω = π).

Shortest-Path Flip

For quaternions, q and −q represent the same rotation. If a · b < 0, interpolation takes the long path (> 180°). Fix:

if (a · b < 0):  b = −b    (before calling slerp/nlerp)

Which to Use

SituationMethodReason
Arbitrary vectors in ℝⁿLerpCorrect; no manifold curvature
Unit vectors (approximate)NlerpFast; adequate for small angles
Unit quaternions (smooth)SlerpConstant angular velocity
Unit vectors (exact)SlerpCorrect geodesic arc
Angles with wrappingAngular lerpHandles 350°↔10° via shortest arc

Angular Lerp (Wrap-Aware)

delta = reduce(b − a, Full)          // shortest signed difference ∈ [−Full/2, Full/2)
result = a + t · delta

This ensures the interpolation takes the short way around.

Reference Files

FileLoad When
references/formulas.mdSlerp derivation, degenerate cases, angle lerp proof
references/numerical-stability.mdNear-identical inputs, antipodal inputs, sin(Ω)→0 handling

Signals

GitHub stars
36
Forks
1
Last commit
Aug 2026
Advanced
Catalog kind
skill
Gateway key
interpolation-on-manifolds
Source
github.com/netfabric/netfabric.numerics