0
102 Oct 02, 2009 at 18:03

The question pretty much sums it up, is it true that:

| A + t * ((B-A)/l) | = 1


for l > 0 and 0 <= t <= l. I can work out the maths, but I got some weird results, so I think I have an error somewhere along the lines. I’ve googled, of course, and found a book saying one should renormalize, but does not state why. If the above does not hold indeed, I would ask you to provide some hints as to what kind of interpolation, if any, will yield this result.

#### 3 Replies

0
165 Oct 02, 2009 at 18:12

No. When you lerp, the interpolated point lies on a straight line between the two endpoints. If the endpoints are on the surface of the unit sphere, the interpolation will trace out a chord of the sphere, not an arc.

You can renormalize after lerping, and this is good enough for many cases (e.g. shaders). It doesn’t however give you a linear relationship between the interpolation parameter (t) and the change in angle (or equivalently, arc length on the sphere) - the nonlinearity being greater the wider is the angle between the endpoints. You can counteract this by using slerping at the cost of some additional math.

Either method (renormalize or slerp) also blows up if you try to interpolate between antipodal points, such as (1, 0, 0) and (-1, 0, 0), as there are then an infinity of possible shortest paths. If you need to handle such points you can special-case it and choose one of the paths arbitrarily.

0
102 Oct 02, 2009 at 18:24

@Reedbeta

No. When you lerp, the interpolated point lies on a straight line between the two endpoints. If the endpoints are on the surface of the unit sphere, the interpolation will trace out a chord of the sphere, not an arc.

OMFG, THANK YOU REED. I went into outburstive maths right away and totally forgot to look for the trivial geometrical interpretation, thanks!

0
101 Oct 02, 2009 at 19:58

If you want a spherical interpolation, take the cross product of the two vectors. The length of that vector is the sine of the angle between the two vectors, and the normalized vector will be the axis of rotation. You can use that to build a rotation matrix about the axis with a lerped angle.

You could also just lerp the vectors and normalize. That will yield the same arc, but not with a constant speed (the point on the arc will move fastest at t=0.5, when the lerped vector is the shortest)