geeks have feelings

Interpolation Tribunal

Series index: Part I, Part II (this post), Part III

Shared-edge “Vernier” comparison: midpoint and one-pass subdivision techniques place boundary vertices at different positions.

In Part I, midpoint recursion and one-pass 1/n refused to line up at equal triangle count. The mismatch pattern was suspiciously structured, suggesting distortion in the algorithms themselves*.

Derp lerp §

Remember that annoying dependency between rounds of midpoint subdivision? That is, we can’t midpoint an edge until we place both of its endpoints on the sphere first? Turns out, skipping that step and just interpolating all the new vertices over each face of the root icosahedron doesn’t solve the dependency; it just means we’re performing linear interpolation (lerp) in 3D Euclidean space instead of on the surface of the sphere via spherical linear interpolation (slerp).

Lerp versus slerp spacingA top-semicircle comparison of equally spaced slerp rays and lerp-plus-normalize rays over quarter-circle arcs.slerplerp + normalize
Arc-space slerp and chord-space lerp on the same semicircle: equal angular spacing on the sphere (orange) can be approximated by equal parameter steps in lerp, but after projection there’s clear distortion in angular spacing (blue points along quadrant I arc).

Visualize this: each round of midpoint subdivision always—and only—places new vertices at edge midpoints. A midpoint on the sphere between two points on the sphere is the same distance and same angle from each endpoint, just like the midpoint of the chord. So, the “project to sphere” step doesn’t change the angular spacing of the inserted vertices.

Now visualize placing a few equally spaced vertices along the root icosahedron’s edge. The edge’s endpoints start on the surface of the sphere, but the inserted points are inside the sphere and farther away from the surface. That inner span travels farther when projected onto the surface. More projection distance causes more magnification, so those equally-spaced vertices can’t stay equally spaced when projected.

Slerp §

Slerp was first published by Ken Shoemake (of quaternion fame): given points on a unit sphere p0 and p1 and a parameter t[0,1] , slerp produces a point on the sphere by interpolating between p0 and p1 along the great-circle arc connecting them (that subtends an angle θ ):

slerp(p0,p1,t)=sin((1t)θ)p0+sin(tθ)p1sinθ

If you stare at it, that’s just stating, “take a lerp-weighted average of the two points in angular space, which is the θ between them, then scale up by (sinθ)1 to maintain constant distance from the origin.” That makes total sense. I love when a formula looks like the way it should look. I think it’s the itch that working on graphics scratches, that the large sparse linear algebra that’s in vogue these days simply can’t reach.

Lerp v. slerp §

How different is lerp from slerp? That question actually has many domain-specific answers, not simply slerp(p0,p1,t)lerp(p0,p1,t) §. For our domain—literally, the domain of the unit sphere—what we care about is the difference between slerp and “projected onto sphere” lerp. Because that difference is—again—on the sphere, it’s better to measure as an angle, not a Euclidean norm distance.

So, compute the sign and magnitude of angular separation of the two points on the sphere. Define shorthands for slerp and normalized lerp:

st=slerp(p0,p1,t),^t=lerp^(p0,p1,t)

Plug and chug into a formula for the signed angle between two vectors:

angular error(t)=tan1(det(st,^t)st^t)

The determinant det(st,^t) is maybe more familiar as the equivalent cross product norm st×^t . This is a perfect case for atan2 to compute an angle of a ratio, which results in the expression atan2(st×^t,st^t) ⁠.

Another part of that domain-specific answer: the error depends on the angle subtended by the edge of the root icosahedron, which is θ=tan1(2) or about 63.4º.

Lerp versus slerp signed angular errorA signed angular-error curve between normalized lerp and expected angle over an icosahedron edge parameter.00.51-1.2°-0.6°0.6°1.2°angular errorθ = tan⁻¹(2)
Signed angular error of projected lerp against true slerp for an icosahedron edge angle: zero at endpoints and midpoint, with mirrored peaks in between.

With the error introduced by lerp characterized, let’s try to improve on it.

Direct slerp subdivision §

Alright, fine. The one-pass method can be even more one-pass-er by combining the interpolation and projection steps into a single, more accurate slerp. Slerp produces the shortest path between two points on a sphere (a geodesic), so we use it to generate n1 new vertices that are already on the sphere and equally spaced in angular distance, then slerp again between those new edge vertices to create the interior vertices, row by row.

Direct slerp construction: vertices are generated directly along great-circle arcs before face fill-in.

At this point, I’m thinking, midpoint recursion is taking spherical geometry more seriously by only operating on points already on the sphere, while the 1/n method is taking a shortcut on an incident plane, with imperfect results.

That story is tidy and I liked that story.

So, since the direct slerp method is doing the same thing™ as the midpoint recursion method, the new tryhard method should definitely recover the wedge mesh from Part I. Now I’m finally going to get that Z-fighting I crave. Before testing that claim, one implementation detail came up.

Spherical interpolation weights §

You can probably see where this is going, so let’s take a practical detour to talk about the direct part of direct slerp. Feel free to skip this section to resolve the cliffhanger.

Using slerp for geometry is great because we can skip the projection step for vertices that are already on the sphere. However, interpolating attributes on top of that geometry is another issue.

The classic slerp blending coefficients are not affine barycentric weights in Euclidean space. They actually don’t sum to 1 except at the t=0 and t=1 endpoints. In fact, their sum produces a plot that looks exactly like an arc over the edge of an icosahedron, which, well, is exactly what it is.

Slerp weight functions and their sumA graph of two slerp coefficient functions and their sum versus interpolation parameter t.00.5100.51sin((1 - t) θ) / sin θsin(t θ) / sin θslerp(0, 1; t, θ), θ = tan⁻¹(2)
Slerp edge weights for the two endpoint vertices and their sum: each endpoint weight behaves as expected, but their sum rises above 1 in the middle.

If you repurpose them directly for per-vertex attributes, you’ll get real errors and they’re not subtle.

Linear versus slerp-weighted color interpolationTwo horizontal ramps comparing linear interpolation against slerp-weight interpolation for black-to-orange color blending.linear gradientslerp-weight gradient (θ = 120°)
Linear-vs-slerp-weight color ramps for vertex uniforms: using spherical weights for ordinary attributes brightens the midpoint and breaks the intended linear blend.

To solve this issue, I had been trying to derive a geometrically correct set of weights (i.e. “reverse project” the slerped point back onto the root face), and even tried to cheat by just normalizing over the coefficients’ sum.

However, for now, I’m using a simpler solution: use ordinary barycentric weights for attribute interpolation. The geometry is still correct because the vertices are still placed correctly on the sphere, and the attributes are blended in a way that’s consistent with the vertices’ angular parameterization. It feels right. I’m all ears for a different perspective (no, not like that) on the in-/correctness of this approach.

Derp… slerp? §

Back to matching the directly slerped wedge against the midpoint method’s wedge.

Overlay at equal triangle count (midpoint in orange, direct slerp in green): they still diverge, and the mismatch pattern isn’t even dihedral symmetric this time.

Nope, again. These two also do not match. And like the previous mismatch between midpoint and one-pass subdivision, it’s still a structured pattern. Strangely, of the faces produced by direct slerp, only those along the last row of faces sit proud of the midpoint method’s faces, but not the others. This lack of dihedral symmetry is a new and unexpected twist, and it suggests that yet again I’ve missed some non-commutativity when composing operations that comprise the direct slerp method.

So now we have three plausible constructions, each spherical-looking, yet no two are equivalent. Sure, we can write off the one-pass method as a performance optimization that sacrifices some accuracy, but what about the other two that are trying to be accurate?

In the next part, I move from aesthetics to scoring the methods with actual measurements, then dive into visualizing where and what the errors are. We’ll get casually into the rigorous geometry and make some hand-wavy logical leaps into applications that I’m no expert in. Finally, I’ll close out the foreshadowing about the midpoint method’s if.

Every Post by Year

  1. 2026
    1. Geodesic Geometrics
    2. Interpolation Tribunal
    3. Better-er Spheres, Fewer-er Triangles
  2. 2025
    1. SSH into Windows 11 WSL2 with Agent Forwarding
  3. 2023
    1. Ducati Timing Belt Replacement
    2. C++ Corrections
  4. 2016
    1. Liftlord
    2. Sensorless Brushless Can’t Even
  5. 2015
    1. Big Data: Test & Refresh
  6. 2014
    1. The Orange Involute
    2. Big Data EVT
  7. 2013
    1. Integer Arithmetic Continued
    2. Real Talk: Integer Arithmetic
    3. Why Microsoft’s 3D Printing Rocks
    4. Flapjack Stator Thoughts
    5. Delicious Axial Flux Flapjack
  8. 2012
    1. How to teach how to PCB?
    2. Fixed-point atan2
    3. It Was Never About the Mileage
    4. Trayrace
    5. BabyCorntrolling
    6. Conkers
    7. BabyCorntroller
    8. Templated numerical integrators in C++
  9. 2011
    1. Bringing up Corntroller
    2. Assembly-izing Tassel
    3. Corn-Troller: Tassel
    4. 5 V to 3.3 V with Preferred Resistors
  10. 2010
    1. HÄRDBÖRD: Interesting Bits
    2. HÄRDBÖRD: Hardcore Electric Longboard
    3. Mistakes to Make on a Raytracer
    4. US International Dvorak
  11. 2009
    1. Raxo
    2. Better Spheres, Fewer Triangles
    3. Donald Knuth Finally Sells Out
    4. Harpy – Sumo Bots 2009