Learn R Programming

polarzonoid (version 0.3-0)

slerp: Spherical Linear Interpolation (slerp) on the Unit Sphere

Description

Let \(u_0\) and \(u_1\) be two unit vectors on the unit sphere \(\mathbb{S}^{m-1}\), that are not antipodal.

The purpose of slerp()is to compute points along the great circle arc from \(u_0\) to \(u_1\), from user supplied interpolation parameters \(\tau\). The value \(\tau{=}0\) produces \(u_0\) and \(\tau{=}1\) generates \(u_1\). For example to generate n uniformly space points, set tau = (0:(n-1))/(n-1) .

If tau=NULL, the points are uniformly spaced and their number is computed automatically, based on the user-supplied parameter thetamax; see Details.

Usage

slerp( u0, u1, tau=NULL, thetamax=pi/36 )

Value

slerp() returns an n x m matrix with computed points in the rows. n is the number of points, and m is the length of u0 and u1. But if n=1, it returns a plain m-vector.

If tau is not NULL, n=length(tau). But if length(tau)==0, the function returns NULL.

If tau is NULL (the default), n = ceiling(theta/thetamax) + 1, where theta is the angle between u0 and u1. If u0 and u1 are equal, then n=1.

In case of error, e.g. u0 and u1 are antipodal, the function returns NULL.

Arguments

u0, u1

numeric vectors with same length (verified) and unit length (not verified). If they are antipodal, the great circle arc is undefined and the function returns NULL.

tau

a numeric vector of interpolation parameters. The default is NULL and then tau is computed using thetamax and the angle between u0 and u1. If tau is not NULL, then thetamax is ignored.

thetamax

the maximum angular step between successive points on the arc. This value must be positive. The default corresponds to 5\(^\circ\).

Details

If both thetamax and tau are not NULL, tau has priority and thetamax is ignored.

When tau=NULL, the angle step \(\Delta \theta\) is computed to be as large as possible and also satisfy \(\Delta \theta \le \theta_{max}\). If the distance between \(u_0\) and \(u_1\) is \(\theta\), the number of points is \(n = \text{ceiling}( \theta / \theta_{max}) + 1\) and \(\Delta \theta = \theta / (n-1)\).

The interpolation formula is not linear; it uses the sin() function. For details see Shoemake.

References

Shoemake, Ken. Animating Rotation with Quaternion Curves. pp. 245-254. SIGGRAPH 1985.