[an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] Skip to the content of the web site.

Spherical Bezier Curves

The templated C++ class Bezier<T, S> defines a spherical Bezier curve between two end points together with an arbitrary number of control points. The points may be of one of the following types:

Quaternion<float> Quaternion<double> Quaternion<long double> Octonion<float> Octonion<double> Octonion<long double> Sedenion<float> Sedenion<double> Sedenion<long double> Trigintaduonion<float> Trigintaduonion<double> Trigintaduonion<long double>

Such a construction makes no sense for complex numbers and therefore this is excluded.

The constructor Bezier( T * q, int n ) takes two arguments: an array q of n points, the first and last of which are the starting and ending points. These points should be unit imaginary numbers.

The single member function with signature T value( S t ) const; where S is either float, double, or long double for a value 0 ≤ t ≤ 1 returns the point on the spherical Bezier curve.

As regular Bezier curves are defined in terms of nested linear interpolation, so spherical Bezier curves are defined in terms of nested spherical linear interpolation.

The best in this case is an example. The following code produces a spherical Bezier curve between the two unit imaginary quaternions q0 = 0.6i + 0.8j and q3 = −0.8i − 0.6k.

#include "Quaternion.h"
#include "Bezier.h"
#include <iostream>
#include <string>
using namespace std;

int main() {
        Quaternion<double> * qs = new Quaternion<double>[4];

        qs[0] = Quaternion<double>(0,  0.6, 0.8,  0.0);
        qs[1] = Quaternion<double>(0,  0.0, 0.6,  0.8);
        qs[2] = Quaternion<double>(0,  0.6, 0.8,  0.0);
        qs[3] = Quaternion<double>(0, -0.8, 0.0, -0.6);

        Bezier<Quaternion<double>, double> bez( qs, 4 ); 

        for ( int i = 0; i <= 10; ++i ) {
                cout << 0.1*i << '\t' << bez.value( 0.1*i ) << endl;
        }

	delete [] qs;

        return 0;
}

The output is a sequence of points on the unit sphere:

0       0 + 0.6i + 0.8j + 0k
0.1     0 + 0.493826i + 0.837774j + 0.232962k
0.2     0 + 0.407199i + 0.842125j + 0.353573k
0.3     0 + 0.346338i + 0.857322j + 0.380854k
0.4     0 + 0.296654i + 0.896563j + 0.328895k
0.5     0 + 0.23343i + 0.950647j + 0.204405k
0.6     0 + 0.128506i + 0.991613j + 0.013775k
0.7     0 - 0.0422426i + 0.973194j - 0.226074k
0.8     0 - 0.286011i + 0.833138j - 0.473369k
0.9     0 - 0.570793i + 0.509867j - 0.643607k
1       0 - 0.8i - 3.35287e-16j - 0.6k

Using the 1001 points t = 0, 0.001, 0.002, ..., 0.999, 1, we get the plot shown in Figure 1.

Figure 1. A spherical Bezier curve between q0 = 0.6i + 0.8j and q3 = −0.8i − 0.6k with two control points.

References