Toby Burnett
The orientation of GLAST, and transformations among the three (at least) coordinate systems that are important to us, involve functions that map the 3-D coordinate space to itself. This is the group known as O(3), the set of all orthogonal 3x3 matrices.
A coordinate system can be defined by its basis, or the
orthogonal unit vectors. In the 3-D case, the coordinate axes are a standard
basis. Given the orthornormal constraint, only two of the directions are
independent. Thus we may represent the orientation of GLAST by the directions
of the x and z axes. Thus we have the FT2 definition of the two (ra, dec) pairs that specify the
directions of the x and z axes. See http://glast.gsfc.nasa.gov/ssc/dev/fits_def/definitionFT2.html.
Since these must be orthogonal, there are actually only three independent
values. A minimal, and standard way to represent three numbers corresponding to
any member of the O(3) group is the Euler angles, a set of successive rotations
about the z, y (or x) and again z axes. The CLHEP class HepRotation
has a constructor that takes this specification. Another way to represent a 3-D
rotation is to specify a direction (a unit vector) and an angle to rotate about
that direction.
The NASA folk who yank our chains have decreed that the only
way to represent members of this group is with a different set of numbers,
represented by a quaternion. (This is
not supported by CLHEP::HepRotation, or in ROOT.) As
the name suggests, it is a set of four numbers. A quaternion is a vector
(actually a pseudovector) and a scalar. If the direction of rotation is the
vector a, and the angle, £ 180
degrees, is a, then the quaternion is
. Thus all such quaternions are normalized such that the sum
of squares is one, and the unit transformation is (0,0,0,1).
There is a algebra of quaternions. The product of two
quaternions, producing another, is
.
Vectors are a subset of quaternions with scalar part zero. The conjugate of a
quaternion (v,s) is (-v,s). Finally, the transformation of a vector t is
.
We now have a class, astro::Quaternion, to manage this algebra. It is implemented as of GlastRelease v9r18. See http://www.slac.stanford.edu/exp/glast/ground/software/status/documentation/GlastRelease/GlastRelease-v9r18/astro/v2r2p3/
It defines member functions that convert from vectors, multiply quaternions according to the above formula, transform vectors, or just return the equivalent 3x3 rotation matrix, and more.
Of particular interest, and the reason for the popularity of quaternions in computer game graphics, is the SLERP, or spherical linear interpolation. From Wikipedia,
In computer graphics, Slerp
is shorthand for spherical linear interpolation, introduced by Ken Shoemake in the context of quaternion interpolation
for the purpose of animating 3D rotation. It
refers to constant speed motion along a unit radius great
circle arc, given the ends and an interpolation parameter between 0 and 1.
We implement this with the interpolate method, with uses the power method. It is how interpolation of the GLAST orientation is now performed.
14 November 2006