Learn R Programming

polarzonoid (version 0.2-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 primary purpose of slerp() is to compute uniformly spaced points along the great circle arc from \(u_0\) to \(u_1\). The angle step \(\Delta \theta\) is computed to be as large as possible and also satisfy \(\Delta \theta \le \theta_{max}\), where \(\theta_{max}\) is a positive user-given parameter. If the distance between \(u_0\) and \(u_1\) is \(\theta\), then \(\Delta \theta = \theta / \text{ceiling}( \theta / \theta_{max})\).

The secondary purpose is to compute points on the great circle arc from user supplied interpolation parameters \(\tau\) = a numeric vector with values typically in [0,1]. The value 0 generates \(u_0\) and 1 generates \(u_1\). For example to generate n uniformly space points, set \(\tau\) = (0:(n-1))/(n-1) .

Usage

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

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.

When using thetamax, n = theta / ceiling(theta/thetamax) + 1, where theta is the angle between u0 and u1. Buf if u0 and u1 are equal, then n=1.

When using tau, n=length(tau). But if tau is empty, the function returns NULL.

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.

thetamax

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

tau

a numeric vector of interpolation parameters. The default is NULL which means to ignore it and use thetamax. If tau is not NULL, then thetamax is ignored.

Details

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

The interpolation formula uses the sin() function. For details see Shoemake.

References

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