...one of the most highly
regarded and expertly designed C++ library projects in the
world.

— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards

template<typename T> quaternion<T> spherical(T const & rho, T const & theta, T const & phi1, T const & phi2); template<typename T> quaternion<T> semipolar(T const & rho, T const & alpha, T const & theta1, T const & theta2); template<typename T> quaternion<T> multipolar(T const & rho1, T const & theta1, T const & rho2, T const & theta2); template<typename T> quaternion<T> cylindrospherical(T const & t, T const & radius, T const & longitude, T const & latitude); template<typename T> quaternion<T> cylindrical(T const & r, T const & angle, T const & h1, T const & h2);

These build quaternions in a way similar to the way polar builds complex numbers, as there is no strict equivalent to polar coordinates for quaternions.

`spherical`

is a simple transposition of
`polar`

, it takes as inputs
a (positive) magnitude and a point on the hypersphere, given by three angles.
The first of these, `theta`

has a natural range of `-pi`

to `+pi`

,
and the other two have natural ranges of `-pi/2`

to `+pi/2`

(as is the
case with the usual spherical coordinates in * R^{3}*).
Due to the many symmetries and periodicities, nothing untoward happens if
the magnitude is negative or the angles are outside their natural ranges.
The expected degeneracies (a magnitude of zero ignores the angles settings...)
do happen however.

`cylindrical`

is likewise a simple transposition
of the usual cylindrical coordinates in * R^{3}*,
which in turn is another derivative of planar polar coordinates. The first
two inputs are the polar coordinates of the first

`multipolar`

is yet another simple generalization
of polar coordinates. This time, both * C*
components of the quaternion are given in polar coordinates.

`cylindrospherical`

is specific
to quaternions. It is often interesting to consider * H*
as the cartesian product of

`semipolar`

is another generator which is
specific to quaternions. It takes as a first input the magnitude of the quaternion,
as a second input an angle in the range `0`

to `+pi/2`

such that
magnitudes of the first two * C*
components of the quaternion are the product of the first input and the sine
and cosine of this angle, respectively, and finally as third and fourth inputs
angles in the range

`-pi/2`

to `+pi/2`

which represent the arguments of the first
and second
In this version of our implementation of quaternions, there is no analogue
of the complex value operation `arg`

as the situation is somewhat more complicated. Unit quaternions are linked
both to rotations in * R^{3}*
and in