200 ORTHOGONAL TRANSFORMATIONS AS VERSORS CHAPTER 7
encoded in terms of geometrical elements of the application, rather than in unrelated
coordinate systems. But is that code also more efficient?
This question is not easily answered. There are many facets to the issue because there
are many different kinds of operations in a geometry, and the balance may differ per
application. When we do a practical comparison for a ray tracer in Part III (see Table 22.1),
the fastest implementation of geometric algebra is 25 percent slower than an optimized,
explicitly written-out classical implementation. That cost of geometric algebr a is about
the same as the performance that can be achieved by the currently commonly used
homogeneous coordinates and quaternions (which provide much less universality than
geometricalgebra).Webelievea5to10percentoverheadfortheuseofgeometric
algebra should be achievable in such applications. This would be an acceptable price
to pay for the much cleaner structure of the code, with a much reduced number of
data types and an elimination of the corresponding special operations that need to be
explicitly defined on them.
Let us briefly discuss some of the relevant issues in making an efficient implementation
of geometric algebra, with special emphasis on the orthogonal transformation of blades,
which will be the structural backbone of geometric modeling in Part II.
•
For the composition of orthogonal transformations, rotors are superior in up to
10 dimensions. The geometric algebra of an n-dimensional space has a general
basis of 2
n
elements. Rotors, which are only even-dimensional, in principle require
2
n−1
parameters for their specification (though typical rotors use only a part of this).
Linear transformations specified by matrices need n × n matrices with n
2
parameters (and typically need them all). Rotors are therefore more efficient for
storage of transformations in less than 7 dimensions (and for the practical dimen-
sionalities of 3, 4, 5 about twice as efficient). Composing transformations as rotors
takes 2
n
operations, and composing them as matrices requires n
3
operations. There-
fore in fewer than 10 dimensions, rotors are more efficient than matrices (in the
practical dimensions 3, 4, 5 about four times more). The reason for this gain by
rotors in composition is partly that they do not represent general linear transfor-
mations, just the orthogonal transformations, and that they can really exploit that
algebraic limitation, whereas matrices cannot. Unit quaternions are rotors in 3-D,
and of course well known to be efficient for the composition of rotations.
•
For the linear transformation of vectors, matrices are always supe rior. To perform
an n×n matrixonann-dimensional vector (orthogonal or not) takes n
2
operations.
A general rotor could require as much as 2
n−1
× n × 2
n−1
= n 2
2(n−1)
in a straight-
forward implementation of its two-sided product. This is always more, in the
practical dimensions about four times more. Part of the computations can be
saved by realizing that grade-preservation of the rotor operation must mean that
some terms cancel (so that they do not need to be computed). Other techniques
may reduce the computation further, but not enough to make the direct rotor
approach competitive. The conversion of a rotor to a matrix may therefore be