Escolar Documentos
Profissional Documentos
Cultura Documentos
to the
right, 90
to the right. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
4.3 Illustration of placement of optical markers (shown as circles) and electromagnetic
sensors (shown as squares) on a subject . . . . . . . . . . . . . . . . . . . . . . . . 71
4.4 Illustration of the marker positions for the HUMOSIM linkage system. For our
experiment we will not have any of the markers below the hip. . . . . . . . . . . . 72
4.5 Handplot of the neutral orientation. The conical cylinder shows the forearm
aligned parallel to the x-axis. The hand is, in turn, aligned to the fore arm with
the palm facing downwards. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
4.6 Histograms of the dierence in the start cuto points and end cuto points between
rotational and translational motion dened as = Rotation Translation. The
units are the number of frames. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
4.7 Plot of a typical angular speed prole. . . . . . . . . . . . . . . . . . . . . . . . . . 78
4.8 Illustration of spherical co-ordinates r, , . Adapted from Weisstein (2006) . . . . 80
4.9 Picture depicting the local orientation of the hand with respect to the forearm
(forearm remains stationary), a handplot, for a reach where the rst order model
t showed a 10
= [v, w]
(2.27)
= [v, w] (2.28)
Norm/Magnitude
q
2
= q q
(2.29)
= w
2
+v v (2.30)
= w
2
+ x
2
+ y
2
+ z
2
(2.31)
Inverse
q
1
=
q
q
(2.32)
Like complex numbers, quaternions can be put in polar form:
q = re
v
2
(2.33)
= r
_
v sin
2
, cos
2
_
(2.34)
17
where r is the magnitude of the quaternion,
2
is the angle (we explain why we have
2
instead of in the next paragraph) and v is the axis which is a unit three vector or
a pure unit quaternion. The above formula can easily be proved by using the power
series expansion of the exponential and then using the fact that v
2
= 1.
De Moivres theorem of powers for complex numbers can be similarly extended
for quaternions giving us:
q
t
= r
t
e
ta
2
(2.35)
= r
t
_
a sin t
2
, cos t
2
_
(2.36)
So how can quaternions be used to parametrize rotation in IR
3
? First of all,
we restrict ourselves to a multiplicative subgroup of quaternions by enforcing unit
magnitude as this is all that is required for rotation parameterization and furthermore
will not change the scale of the object being rotated
5
. Let x be a vector in IR
3
and
suppose we wish to rotate this about an axis a by an angle . Then the rotation
formula in quaternions would be of the form:
y = q x q
1
(2.37)
where q =
_
a sin
2
, cos
2
_
and y is the rotated vector and both x and y are in pure
quaternion form. Thus to rotate a vector x we need to put it in quaternion form and
then multiply to the left with the rotation quaternion and multiply to the right by
its conjugate. Thisdouble multiplication is the reason why we have
2
instead of
in our quaternion parameterization.
The identity quaternion given by:
q
I
= (0, 0, 0, 1) (2.38)
5
From now on all quaternions will be unit unless otherwise indicated.
18
is the unit scalar quaternion it plays the role of the identity matrix, i.e., it rep-
resents a zero rotation. Like the matrix the identity quaternion has the following
properties:
q q
I
= q
I
q = q (2.39)
q q
1
= q
1
q = q
I
(2.40)
Another property of this formula is that q and q would produce the same rota-
tion and thus we have a problem of double-coverage. As mentioned previously, the
only parameterization that does not suer from multiplicity is the rotation matrix.
Although we acknowledge the quaternion multiplicity, it can be handled using some
straight-forward techniques that are described in section 3.3.5.
Concatenation of rotations is handled similarly to that of matrices due to the
non-commutative nature of quaternion multiplication. Thus if we wish to rotate by
q
1
followed by q
2
. By the quaternion rotation formula we have:
y = q
2
(q
1
x q
1
1
) q
1
2
(2.41)
= (q
2
q
1
) x (q
2
q
1
)
1
(2.42)
It is useful to look at the unit quaternions from a geometric and topological point
of view as it provides us with a fair amount of intuition as to how the unit quaternions
work. If we think of unit quaternions as unit vectors in IR
4
then the space of unit
quaternions is the surface of a four dimensional hypersphere denoted as S
3
(the 3
stands for the three degrees of freedom that exists for this surface and not the number
of dimensions which is four) in the literature. Thus the double coverage problem can
be interpreted as antipodal symmetry as q and q are antipodes or, in other words,
on direct opposite sides of the sphere.
19
The main advantage of the quaternion representation is that it does not suer
from a co-ordinate singularity. This can be explained through what is known as the
Hairy Ball Theorem in topology. It states that if we have a ball covered with hair
we cannot comb the hair such that all the hairs lie at on the surface of the ball.
In other words, it is impossible to create a continuous tangent vector space on the
surface of a sphere with an even number of degrees of freedom. The corollary to this
is that it is possible to do this for spheres with odd degrees of freedom. Since unit
quaternions live on S
3
we can move smoothly on the surface of the sphere without
encountering any discontinuities.
Quaternions can be thought of as a more ecient representation than rotation ma-
trices as it uses four numbers instead of nine. Quaternion multiplication requires less
calculation than matrix multiplication
6
and as such algorithms for quaternions run
almost ve times faster than those for rotation matrices. Numerical round-o errors
are much more easily handled with quaternions requiring simple re-normalization as
opposed to matrices that require re-orthonormalization through Gram-Schmidt or
other such computationally expensive methods.
The perceived disadvantage of quaternions are that they are dicult to interpret.
However, quaternions in polar form makes it trivial to relate it to Eulers Theorem
with the axis and angle easily obtained. The problem lies in the fact that quaternions
are unfamiliar to a majority of people as they are seldom taught in basic college level
math courses. By using the geometric interpretation of quaternions one can avoid
thinking of them as a black box.
The major problem we face when using quaternions is that they live on the surface
of a hypersphere and thus we cannot use the familiar Euclidean vector space methods,
6
Quaternion multiplication requires 16 scalar multiplies while matrix multiplication requires 81.
20
statistical or otherwise. This is a problem inherent in the rotation group and is not
just as a result of choosing quaternions as our parameterization method. This will be
discussed in more detail in the next chapter where we introduce orientation statistics
and formulate methods to model quaternion data.
2.2.5 References
The information presented in this chapter were taken from many dierent sources.
Much of the information in the section on quaternions was obtained from Shoemake
(1985), (1987) and from the man who discovered them, Hamilton (1866). There are
also references that look at all the parameterizations: Buss (2003) and Goldstein
(1980). Two websites that have a wealth of information are: Baker (2006) and Weis-
stein (2006).
CHAPTER III
Statistical Analysis of Orientations
In this chapter we will introduce statistical methods for analyzing orientation
data using the quaternion method of parameterization with an emphasis on human
motion. A detailed description of this type of data precedes the statistical analysis.
We then introduce the natural metric for orientation data as well as the concept of
a mean orientation.
We consider two possible approaches to handling quaternion data:
1. The Tangent Mapping approach where we map our quaternions from S
3
onto
a tangent space.
2. The Constraint approach where we stay in S
3
and consider it a constrained
subspace of IR
4
.
We describe both approaches and derive statistical models for each.
3.1 Human Kinematic Data: Links, Joints and Co-ordinate Frames
Before we dive into the statistical analysis we need to introduce the type of data
that we are trying to model and describe some of the issues involved.
The human body can be modeled conceptually as a chain of rigid links or seg-
ments connected together by joints. These segments represent body parts which are
21
22
considered to be rigid in that they are considered not to bend or stretch. The joints
connect these segments and allow rotational movement between segments. Depend-
ing on the joint, we have up to three rotational degrees of freedom available for a
particular body segment.
How many links and joints there are depends on the particular linkage system
used which needs to be chosen by the experimenter. The linkage system also eects
the number of rotational degrees of freedom each joint allows. For example, let us
consider the arm, which is made up of the hand linked to the forearm via the wrist
joint and the forearm linked to the upper arm via the elbow joint. Intuitively, we
would allow three degrees of freedom for the orientation of the hand as we can move
it up or down, left or right as well as twist it along the axis of the forearm. The
twist, however, does not really occur at the wrist joint but rather along the forearm
due to the action of the tendons. It is thus possible to allow the twist to occur at
the elbow thus giving the elbow and the wrist two degrees of freedom each rather
than the usual three for the wrist and one for the elbow.
We obtain our data via the use of motion capture for which we place markers
on certain landmark points on a subjects body and use cameras or other sensors to
track the location of these markers as the subject performs prescribed tasks. Our
raw human motion data consists of the marker positions recorded in xed frequency
intervals with respect to an arbitrary global co-ordinate system set up by the motion
capture device. From these marker positions we calculate the positions of the joint
centers corresponding to the linkage system that we are using. Data from each
individual frame are called posture data and a series of posture data over time are
called motion data.
The orientation of a particular body segment can be obtained with respect to the
23
Figure 3.1: Illustration of the HUMOSIM linkage system. The reference posture shows the human
gure standing erect, facing forward and holding the arms outstretched to the sides
parallel to the ground with palms facing downward. Each body segments local co-
ordinate system is shown aligned with the global co-ordinate system marked as X0-
Y0-Z0
24
global co-ordinate system or the co-ordinate system induced by the segment that
directly precedes it in the chain called the local co-ordinate system (see gure 3.1).
We denote a quaternion that represents the orientation of a segment with respect
to the global co-ordinate system as a global quaternion and similarly for a local
quaternion. The global quaternion for each segment is calculated from the marker
locations. The simplest way to do this is to form a rotation matrix using the basis
vectors that form the co-ordinate system of the segment. We can then convert
1
this
to obtain the global quaternion. As an example suppose we have two segments A
and B with B preceding A in the chain. Let us denote the global quaternion for A
as
G
A
q and the global quaternion for B as
G
B
q. This can be read as the quaternion for
segment subscript with respect to the co-ordinate system superscript. Once we
have these we can obtain the local quaternion of A with respect to the co-ordinate
system of B by:
B
A
q =
B
G
q
G
A
q (3.1)
=
G
B
q
G
A
q. (3.2)
Whether we choose to use global or local quaternions, we extract the orientation
from each posture in the motion and create an orientation trajectory for that segment.
These trajectories, which will vary in length depending on the speed at which the
motions are performed, will then form our response. This choice is an important one
however, with advantages and disadvantages on both sides. We will discuss these in
the next chapter when we perform an example analysis and model the orientation
trajectory of the right hand during reaching tasks.
1
See Appendix for the various conversion algorithms between rotation parameterizations.
25
3.2 The Angle of Rotation Metric for Orientations and the Mean
Orientation
It is obviously important for a distance metric to be dened for us to move ahead in
statistically modeling and analyzing orientation data. As mentioned in the previous
chapter, Eulers Rotation Theorem provides us with a natural angle of rotation metric
between orientations. Since we have made the choice of using quaternions as our
parameterization method we need to be able to obtain this metric from them.
Let q
1
and q
2
be two quaternions representing dierent orientations. Then the
rotation required to go from q
1
to q
2
is given by:
q
new
= q
1
q
2
(3.3)
From the previous chapter we know that the angle of rotation can be obtained
from the scalar component of a quaternion and thus if we apply this to the new
quaternion we calculated we get
2
:
new
= 2 arccos |scalar(q
new
)| (3.4)
= 2 arccos |scalar(q
1
q
2
)| (3.5)
= 2 arccos |w
1
w
2
+v
1
v
2
| (3.6)
= 2 arccos |q
1
q
2
| (3.7)
Thus the angle of rotation metric for quaternions is also the angle formed between
them at the origin. Since S
3
has unit radius this can also be thought of as the length
of the shortest geodesic between them.
3
2
Absolute values are taken so as to remove the antipodal symmetry property. This way it will always return the
angle from the closer antipode.
3
The geodesic is dened as a locally length minimizing curve. On the sphere the geodesic is a great circle linking
the two points on the hypersphere.
26
With this metric we can now dene a mean or average orientation. In normal
p-dimensional Euclidean space the mean can be dened as:
(3.8) x = arg min
xIR
p
n
i=1
|x
i
x|
2
We can describe the mean orientation in an analogous way with Euclidean distance
replaced with the angle of rotation metric. For the quaternion parameterization this
becomes:
(3.9) q = arg min
qS
3
n
i=1
arccos |q
i
q|
2
.
Buss and Fillmore (2001) describes an iterative solution to this minimization. As
with all iterative algorithms there are issues with speed and accuracy. We shall call
this the Minimum Distance mean.
Prentice (1989) described an alternate method of obtaining this mean which he
derived from the mean rotation matrix. Suppose we have a sample of n orientations in
rotation matrix form i.e. X
1
, . . . , X
n
from SO(3) and we are interested in obtaining
the mean orientation. A naive estimator would be the element-wise arithmetic mean,
X =
1
n
n
i=1
X
i
(3.10)
=
1
n
n
i=1
_
_
_
_
_
_
_
x
i
11
x
i
12
x
i
13
x
i
21
x
i
22
x
i
23
x
i
31
x
i
32
x
i
33
_
_
_
_
_
_
_
(3.11)
=
_
_
_
_
_
_
_
1
n
n
i=1
x
i
11
1
n
n
i=1
x
i
12
1
n
n
i=1
x
i
13
1
n
n
i=1
x
i
21
1
n
n
i=1
x
i
22
1
n
n
i=1
x
i
23
1
n
n
i=1
x
i
31
1
n
n
i=1
x
i
32
1
n
n
i=1
x
i
33
_
_
_
_
_
_
_
(3.12)
where x
i
jk
is the jkth element of the ith sample matrix. Unfortunately this estimator
is not a rotation matrix. To solve this problem we need to decompose this mean
27
matrix into matrix polar form. The following denition is taken from Downs (1972).
Definition. Let F be a 33 square non-singular matrix. The matrix M.K is called
a polar form of F, with Mthe polar component and Kthe elliptical component, where
(1)F = MK, (2)M
T
M = I, det(M) = 1 and (3)K is symmetric positive-denite.
There exists a relationship between matrix polar forms and least squares in that
M = arg min
X
tr{(F X)
T
(F X)} for all X SO(3). As F
T
F and X
T
X are
constant, this is equivalent to M = arg max
X
=tr(F
T
X).
To numerically evaluate the decomposition of F into its matrix polar form requires
us to rst of all look at its singular value decomposition,
(3.13) F = D
=diag(
1
,
2
,
3
) is positive denite
with
1
>
2
>
3
being the singular values of F. The polar component is then
M = and the elliptical component is K = D
T
.
The arithmetic mean,
X =
1
n
n
i=1
X
i
, is not a rotation matrix as stated previ-
ously. However if we were to put it in polar form
X = M.K, the polar component
M is a rotation matrix. In fact, it is the rotation matrix that is closest in the least
squares sense to
X.
One can show that
(3.14) tr(
X
T
M) = 4m
T
(
1
n
n
i=1
q
i
q
T
i
)m1
where q
1
, . . . , q
n
S
3
are the quaternion representations of X
1
, . . . , X
n
SO(3)
and m is the quaternion corresponding to M. From this it can be proved that m
is the eigenvector corresponding to the largest eigenvalue of the moment of inertia
28
matrix
(3.15) I =
1
n
n
i=1
q
i
q
i
It is dicult to gain any intuition from this Eigenvector mean and attempts to nd
a meaningful interpretation from the literature were unsuccessful. We also could not
nd in the literature if there was a relationship between the minimum distance mean
and the eigenvector mean. We were able to prove that they are, in fact, identical.
The rst step to the proof is to recognize that:
q = arg min
qS
3
n
i=1
arccos |q
i
q|
2
(3.16)
= arg max
qS
3
n
i=1
(q
i
q)
2
(3.17)
The next step is to use the Lagrange multiplier to solve this equation under the
constraint that the solution lies in S
3
. We rewrite the equation by expressing the
dot product as an inner product of the quaternions expressed as vectors in IR
4
. Thus
we have:
f(q) =
n
i=1
(q
T
q
i
)
2
+ (q
T
q 1) (3.18)
=
n
i=1
_
(q
T
q
i
)(q
T
i
q)
+ (q
T
q 1) (3.19)
= q
T
_
n
i=1
q
i
q
T
i
_
q + (q
T
q 1) (3.20)
= q
T
Iq + (q
T
q 1) (3.21)
Dierentiating with respect to q:
(3.22)
q
f(q) = 2Iq + 2q
which when equated to zero leads us the eigenvector equation Iq = q. Maximization
of the objective function will occur when q = e
1
the eigenvector associated with the
29
largest eigenvalue, thus proving the result. Now that we know the two are equivalent
the eigenvector method will be preferred over the minimum distance method due to
ease of computation. The only time one would use the latter is that it allows us to
incorporate weights and thus calculate a weighted average.
3.3 The Tangent Mapping Approach
As we have mentioned in the previous chapter, the main problem we face when
working with the quaternion representation of orientation is that we are working in
a non-linear space, which in this case is the surface of a unit 4D hypersphere.
One way we can get around this problem is to make use of a fact from group
theory which states that the surface of a 4D hypersphere is a Lie group. The tangent
space taken at a Lie groups identity is known as a Lie algebra and the Exponential
map is used to move between the Lie Group and the Lie algebra (see gure 3.2).
The Lie algebra for the space of unit quaternions is Euclidean IR
3
and therefore if
we map our unit quaternions onto this tangent space we have essentially a relatively
straight forward method to getting around the non-linearity problem.
3.3.1 Exponential and Logarithm maps for Quaternions
In the previous chapter we saw that the polar form of a quaternion is basically an
exponential of a vector in pure quaternion form:
q = e
v
2
(3.23)
The logarithm of a quaternion is the inverse of the exponential and is dened as:
log q = v
2
(3.24)
In fact exponentiation is dened only for pure quaternions and conversely the loga-
rithm of a quaternion always results in a pure quaternion. Since a pure quaternion is
30
Figure 3.2: Illustration of the exponential map and the logarithm map which allows us to move
between quaternions which are on the surface of the sphere to points on the tangent
space taken at the identity
a vector we see that the above denitions give us a way of mapping between vectors
and quaternions.
For the purposes of computation we dene the exponential map as:
(3.25) expmap(v) =
_
_
[0, 1] if v=0
[ vsin
2
, cos
2
] if v=0
where v IR
3
, = v and v = v/. We compute the logarithm map by:
(3.26) logmap(q) =
v
sinc
2
where v is the vector part of q and sinc(x) =
sinx
x
which is known as the sink function
and is dened as x tends to zero
4
.
4
We can see this from the Taylor series expansion of the sink sinc
_
2
_
= 1 +
2
24
4
2
4
5!
+. . .
31
As we can see, the exponential and logarithm maps act as almost a conversion
algorithm between quaternions and the axis-angle representation with the exception
that the angle is not explicitly obtained but rather represented by the magnitude of
the axis.
From the above denitions, we notice that work is needed for this mapping to be
unique. The rst thing we need to do is restrict
2
to be between [0,
2
]. Thus the
exponential map will take points from a ball of radius
2
to the quaternions. Unfortu-
nately this mapping is unique only for the interior points of the ball; antipodal points
on the surface of the ball represent the same rotation. This is because a rotation of
about v or v results in the same orientation. Since the log mapped quaternion
is a minimal representation using just three parameters, it is to be expected that it
would suer from a singularity. Luckily, this region is well dened as opposed to the
gimbal lock singularity region of Euler angles.
An important property of the exponential map is that it preserves the angle metric
between the identity and each orientation, i.e.
(3.27) logmap(q) 0 = arccos |q q
I
|
As a by product of this, it also preserves the angle formed at the identity between
longitudinal lines.
5
This means that hyper circles or hyper ellipses on S
3
centered
on the identity maps to spheres and ellipsoids on the tangent space.
This tangent mapping approach is a local linear approximation and as such the
further our data is from the identity the more distorted our approximation becomes.
The exponential map does not preserve the angle metric between two quaternions
unless one of them is the identity and the further away from the identity these points
5
Think of longitudinal lines on the Earth. They all lie on great circles that pass through the north and south
poles.
32
are the greater the discrepancy between the angle metric on S
3
and the Euclidean
metric on the tangent space.
The exponential and logarithm map formulae are dened such that the tangent
space is taken at the identity. This is not a problem if our data is centered at the
identity but it is far more likely that this is not the case. To take the tangent space
at a point other than the identity we need to rotate our data such that our tangent
point coincides with the identity. This is essentially a change of coordinate system.
Suppose we have n data points q
1
,. . . , q
n
and we wish to map these quaternions to
the tangent space taken at q. We need to rotate our data such that q becomes the
identity. The rotation required is the conjugate q
q
1
, . . . , q
q
n
.
We can then use our existing formulae to map to and from the tangent space remem-
bering to multiply to the right by q to return to our original co-ordinate system.
A good explanation of the exponential and logarithm maps are given in Grassia
(1998) while explanations of Lie groups and Lie algebras can be found in Weisstein
(2006).
3.3.2 Distribution Theory on the Tangent Space
Coming up with a plausible probability distribution for quaternions native to S
3
is not a simple task but there are some that have been developed, most notably the
Bingham distribution which we will talk about in a later section. We can, however,
describe the likely characteristics such a distribution would take. Suppose we are
looking to model the orientation of the hand when a person initially grasps a door-
6
Quaternion multiplication is non-commutative and so we need to keep track of which side we performed our
multiplication so that we can return to our original co-ordinate system when we map back from our tangent space
33
(a) In 3D (b) In 2D
Figure 3.3: Illustration of the Tangent Gaussian distribution in lower dimensions.
knob before opening a door. We would reasonably expect there to be a single most
probable orientation the hand will take and a continuum of less probable orientations
the further we get from that modal orientation. In such cases a Gaussian distribution
centered at the mode appears to be a reasonable potential candidate.
Antipodal symmetry of quaternions means that the distribution needs to be bi-
modal since q and q represent the same orientation they should obviously be equally
likely. If we were to visualize S
3
as the earth then we can imagine the North and
South poles being the modes with the distribution being mirror images of each other
above and below the equator. Thus it is possible to restrict ourselves to just one
hemisphere and then ip any quaternion that is in the wrong hemisphere by taking
its antipode.
In the tangent mapping approach, we will use a standard zero-mean trivariate
Gaussian density as our model for the tangent vectors taken at one of the modes.
Thus the density can be written as:
(3.29) f(q; , m) =
1
2
3
2
||
1
2
e
1
2
v
T
v
,
34
where v = logmap(m
1
2
P
T
logmap(q m
)
where Dand P are the diagonal matrix of eigenvalues and its corresponding matrix of
eigenvectors, respectively, obtained from decomposing the covariance matrix . Thus
the Mahalanobis distance can be interpreted as the number of standard deviations
away from the mean our data is.
Let be the value of this distance that denotes the joint range of motion limit. A
logical estimator of is the maximal Mahalanobis distance obtained from our data,
i.e.,
(3.32) = max
qq
1
,...,qn
(d
Mah
(q)).
One needs to keep in mind that this estimator is dependent on the point at which
we take our tangent space m and therefore we need to make sure when we apply this
limit that we are in the correct space.
Obviously, the quality of this estimated limit depends on the quality of the data.
We would ideally like for the data to be a random sample of orientations where the
joint reaches the boundary of its range of motion limit. We will discuss the problems
that arise when this assumption does not hold true when we apply our limit to real
experimental data in chapter four.
3.3.4 Interpolation and Smoothing
The basic fundamental interpolator between two quaternions is the spherical
l inear interpolator or slerp introduced by Shoemake (1985). It interpolates along
37
the shortest geodesic path which in this case would be the great circle arc that goes
through the two quaternions. The slerp between two quaternions q
1
and q
2
is given
by:
(3.33) slerp(q
1
, q
2
, ) =
sin(1 )
2
sin
2
q
1
+
sin
2
sin
2
q
2
,
where cos
2
= q
1
q
2
. Visualizing this geometrically, we see that the slerp embodies
Eulers rotation theorem in that it nds the rotation that will take it from the initial
to the nal orientation and the interpolation path is obtained by varying the angle
of rotation around the rotation axis.
The slerp interpolator is native to S
3
and is not necessarily preserved on the tan-
gent space, i.e. the slerp interpolation path between two quaternions when mapped
onto the tangent plane does not equal the interpolation path obtained by using
a normal convex sum based linear interpolation between the two tangent mapped
quaternions. It is preserved, however, if either the initial or the nal quaternion is
the point at which the tangent space is taken. This is directly due to the fact that
the exponential map preserves the angle of rotation metric of a quaternion from the
identity.
Unfortunately, the likelihood that our motion data contains just two key frames or
postures is basically zero, and the slerp cannot be used to create a smooth interpola-
tion path between more than two. A more complex spline-type approach is required
for this. With the tangent mapping approach we are no longer restricted to the the
surface of the hypersphere, and thus we can call upon an abundance of well-dened
methods. Prentice (1987) also uses this idea, employing the exponential map derived
directly from SO(3), which is also a Lie group and is a higher dimensional extension
of the method by Jupp and Kent (1987).
38
The approach we will be taking is to t regression splines
8
to our tangent mapped
quaternion trajectories using cubic B-spline basis functions. The reason we make this
choice is two-fold; we reduce the dimensionality of our data and by using an equal
number of uniform knot points, combined with a rescaling of actual time to relative
time, we can circumvent the problem of having varying lengths for the trajectories.
Dimension reduction is a major issue with motion data as a ve second motion
captured at a frequency of twenty hertz will lead to a hundred quaternion data
points on our orientation trajectory. This is the method used by Faraway (2000)
except that we have a trivariate response instead of a univariate one.
Let us denote the function we are approximating as q(t). The spline function is
given as a linear combination of m cubic B-spline basis functions,
m
j=1
p
j
j
(t), and
the objective is to choose control points p
j
such that we minimize:
(3.34) (t) =
_
_
1
0
q(t)
m
j=1
p
j
j
(t)dt
_
2
,
where t [0, 1] denotes proportional time. Since we only observe q(t) at xed
intervals the problem in matrix equation form becomes to minimize:
(3.35) tr(E
T
E),
where
(3.36) E
n3
= Q
n3
nm
P
m3
,
and n denotes the number of frames or postures in the observed trajectory. The
matrix is made up of the basis function values and its derivation is given in the
appendix . Using least squares, the matrix of spline control points, P, is calculated
as:
(3.37) P = (
T
)
1
T
Q.
8
This method implies that we are approximating the trajectory and not interpolating it.
39
The raw marker data obtained from the measurement devices tend to have a lot
of noise. Filtering methods are used to smooth the marker data and consequently
produce smooth orientation trajectories. Due to this ltering, sensitivity with the
choice of m is normally not an issue. We want to choose m to be large enough to
capture any true systematic patterns but not so large that it will start capturing any
random noise elements.
3.3.5 Hemisphere Commonization and Data Concentration: The Slerp Residual
The exponential and logarithm map, as we have dened it, is a mapping between
one hemisphere of S
3
and a subset of IR
3
, namely the ball of radius
2
. Thus we
require the data to be in the hemisphere centered at the point at which the tangent
is taken which we will call the tangent hemisphere. As quaternions are antipodally
symmetric this is not a hard problem: we need only choose the antipode closest to
the tangent point.
Here is a simple, two-step algorithm for achieving this common hemisphere. Sup-
pose that we have posture data q
1
, . . . , q
n
and we wish to take the tangent at q
(normally the mean). The steps are:
1. Calculate q q
i
for i = 1, . . . , n.
2. If q q
i
< 0 then replace q
i
with q
i
.
This ipping method where we take the antipode of quaternions not already
in the tangent hemisphere is suitable for posture data, but there exists a potential
problem with applying it to motion data. Suppose we have an orientation trajectory
that is close to the hemisphere border and that it passes through it. The ipping
algorithm would then result in the sections of the trajectory that were in the non-
tangent hemisphere being ipped to the opposite side of the sphere thus introducing
40
Figure 3.4: Illustration of the potential problem in using the ipping algorithm on an orientation
trajectory that exists on the boundary between hemispheres. The original trajectory
starts in the upper hemisphere and curves down to the lower hemisphere before returning
back to the upper hemisphere. Using the ipping algorithm we would ip our smile
on the lower hemisphere to the other side of the sphere to create a frown on the upper
hemisphere.
discontinuities to the path, as seen in gure 3.4. This makes it impossible for us
to apply not only the interpolation and spline techniques mentioned previously, but
any functional analysis of trajectory data.
For this reason we introduce the concept of slerp residuals. The slerp interpolator
introduced previously can be thought of as astraight line model that creates a
straight trajectory from an initial orientation to a nal orientation. We dene the
slerp residuals to be the dierence between the actual orientation trajectory and
the slerp model trajectory. By dierence we mean the rotation required to take
us from a point on the slerp model trajectory to a corresponding point on the actual
trajectory. This is graphically illustrated in gure 3.5.
Suppose we have an orientation trajectory made up of n observed posture orien-
tations, q
1
, . . . , q
n
. The rst step in obtaining our slerp residuals is to calculate our
slerp model trajectory. One possible method for obtaining our trajectory is to use
41
(a) Slerp Model Trajectory (b) Slerp Residuals
Figure 3.5: Illustration of the slerp model and the slerp residuals. The slerp model(a) gives the
shortest trajectory on the sphere between two points. The slerp residuals (b) are the
rotations, shown as arrows, that take us from the slerp trajectory to the actual observed
trajectory
the slerp interpolator to create n equally spaced postures, i.e., the angle between
each subsequent posture orientation is constant. Our slerp trajectory would then be
(3.38)
q
1
, slerp
_
q
1
, q
2
,
1
n 1
_
, slerp
_
q
1
, q
2
,
2
n 1
_
, . . . , slerp
_
q
1
, q
2
,
n 2
n 1
_
, q
n
,
which gives us an orientation trajectory that has a constant rotational speed or a
constant angular speed prole. Such a model is unrealistic as people do not move at
constant speeds unless trying to do so on purpose. However, that is not a problem for
the purpose of calculating slerp residuals. The angular speed prole of the observed
trajectory, q
1
, . . . , q
n
, will be passed on to the slerp residuals as one that is relative
to a constant speed prole.
The purpose of the slerp residuals is not only for us to avoid the potential of
a discontinuity being introduced by the ipping algorithm, but also to reduce the
spread of our data as much as possible by concentrating it around the identity.
This improves the quality of our linear approximation on the tangent plane which
is obviously a desirable objective. The way to maximize the concentration of the
42
slerp residuals is to apply the angular speed prole from our observed trajectory
to our slerp model trajectory. The constant speed slerp model would result in less
concentrated slerp residuals.
Note that we are using an angular speed prole and not a velocity prole. The
slerp interpolator produces orientations from a xed axis of rotation and so these
two are the same but for our observed trajectory it is unlikely that we have one.
Thus we need to ignore the directional aspect of a velocity prole and use a speed
prole instead. We calculate the angular speed prole of an orientation trajectory,
q
1
, . . . , q
n
, as:
(3.39) s
i
= arccos |q
i
q
i+1
|
for i = 1, . . . , n 1.
Using this angular speed prole we create the following speed adjusted slerp model
trajectory:
(3.40)
q
1
, slerp
_
q
1
, q
2
,
s
1
n1
i=1
s
i
_
, slerp
_
q
1
, q
2
,
2
i=1
s
i
n1
i=1
s
i
_
, . . . , slerp
_
q
1
, q
2
,
n2
i=1
s
i
n1
i=1
s
i
_
, q
n
.
We now have a slerp model trajectory s
1
, . . . , s
n
, whether it is speed-adjusted or
constant, along with our observed trajectory q
1
, . . . , q
n
and from these we calculate
the slerp residuals as:
(3.41) r
i
= s
i
q
i
,
for i = 1, . . . , n. As with all quaternion multiplication we need to be cognizant of
the order in which this is done due to non-commutativity.
Since q
1
= s
1
and q
n
= s
n
, we have that r
1
= r
n
= q
I
, the identity quaternion.
Thus we have, in eect, transformed our data to form slerp residual trajectories
43
that start and end at the identity. The extent to which we have concentrated our
data depends upon how close our slerp model trajectories are to the actual observed
trajectories, but it should result in data that are much less spread out and therefore
entirely remove the incidence of discontinuous trajectories formed by the ipping
algorithm.
The drawback with this residual approach is that we lose information on the
starting and ending orientation of our trajectory. Thus we would need to either
predict these separately or be given this information as input, which is usually the
case. On the other hand, if the task is to predict an orientation trajectory that is
constrained to start and end at specied orientations then this method is the only
viable way of doing so.
3.3.6 Functional Regression Modelling of Orientation Trajectories
Our ultimate goal, as we mentioned in the introduction, is to model the three
degrees of freedom orientation trajectories of certain body segments during human
motion with respect to covariates such as age, anthropometry, gender, target location
and starting and ending orientations. Our approach is to treat these trajectories
as functions and therefore use statistical functional data analysis techniques. The
reference for this sort of analysis is the book by Ramsay and Silverman (1997).
All of the sections in this chapter preceding the current one have dealt with
methods that we need for us to be able to perform a functional regression analysis
of our quaternion orientation trajectories on the covariates listed above. Faraway
(1997) introduces this functional regression model for univariate functions. Suppose
we have n response functions given by y(t) = (y
1
(t), . . . , y
n
(t) and x
i
being the p-
variate vector of covariates for the ith response function. The functional linear model
44
is then given by:
(3.42) y
i
(t) = x
T
i
(t) +
i
(t).
This is similar to the standard regression model except that the response y
i
(t), error
term
i
(t) and vector of regression coecients (t) are now all functions. We can
interpret the jth coecient function
j
(t) for j = 1, . . . , p as the eect of the jth
covariate on the entire response function given a xed level of the other covariates.
We can estimate (t) using least squares by:
(3.43)
(t) = (X
T
X)
1
X
T
y(t)
where x is the n p matrix of covariates whose rows are given by the x
i
s.
A cubic B-spline basis approach is used to approximate the response functions for
the same reasons as those mentioned in section 3.3.4. Thus we have
(3.44) y
i
(t)
m
k=1
y
ik
k
(t).
We can now use the spline control points y
ik
in place of our functional response y
i
(t),
in eect converting our problem from a functional to a multivariate one. Thus the
B-spline approximation of the above model can be written as:
(3.45) Y
nm
m1
(t) = X
np
B
pm
m1
(t) +
nm
m1
(t),
where m is the number of basis functions used and (t) is the vector of those basis
functions. By factoring out (t) we obtain:
(3.46) Y
nm
= X
np
B
pm
+
nm
,
which is a multivariate regression model of the spline control points on the covariates.
We then estimate B using standard least squares:
(3.47)
B = (X
T
X)
1
X
T
Y.
45
As we have stated at the beginning of this chapter, the problem we face with
our quaternion trajectory data is that it is non-linear and therefore we cannot t a
linear model such as the one we have just described. However, by using the tangent
mapping approach we can linearize our data, thus opening the way for linear models
to be t. Since this is a local linearization at the tangent point, our approximation
gets worse the further away we get from this tangent point. We would like, ideally,
to have our quaternion trajectories concentrated close to the tangent point.
How accurate and reliable our methods are depends on the spread or variability
of the data that we are working with. In our application of human motion, this vari-
ability will depend in part on how wide a range of orientations the particular body
segment we are modeling can take. The wrist allows, perhaps, the most amount of
exibility and thus orientation data for the hand will tend to have more variability
than say that of the foot where the ankle allows a markedly smaller range of orienta-
tions. If the variability of the data is such that we have a large number of trajectory
observations close to the tangent hemisphere border we will have to use the slerp
residual method derived previously to concentrate our data.
Let us denote these quaternion trajectories or functions as q(t) = (q
1
(t), . . . , q
N
(t))
where each trajectory observation q
i
(t) consists of diering numbers of observed pos-
tures (q
i1
, . . . , q
in
i
) for all i.
1. The rst task is to nd the average of all the postures in our data using the
Eigenvector method:
(a) Form a 4 M matrix Q of all our M = n
1
+ +n
N
quaternion postures
in column vector form.
(b) Calculate the moment of inertia matrix T = QQ
T
.
46
(c) Perform an eigendecomposition of T.
(d) The mean q is the eigenvector associated with the largest eigenvalue.
2. The mean q is the point at which we will take our tangent.
3. Check on the spread of our data to see if there are any quaternions that are
close to away from q in terms of our angle of rotation metric, i.e. check if
2 arccos( q q
ij
) >= . If so, we will have to use a slerp residual analysis. If,
as in the case for our model in chapter 4, we are asked to make predictions
for orientation trajectories that start and end at user-dened positions then we
would have to use the slerp residuals.
4. First try the constant speed slerp residuals to see if that is enough to pull our
data away from the hemisphere border. If that is not achieved then we will have
to go with the speed-adjusted slerp residuals.
The reason we would prefer to use the constant speed residuals is because it
allows us to directly convert any eventual predictions we make from our functional
regression model back to a real orientation trajectory. For speed adjusted slerp
residuals, we would need to predict an angular speed prole for us to be able to
convert our predicted residual trajectories back. Whichever method we use, we will
end up with slerp residual trajectories for which we will have to nd the mean. Let
us denote these trajectories as R(t) and the mean as r.
Let us assume that we have made use of the slerp residuals, otherwise we would
just proceed through the next steps using our original data. The next step is to
use the logarithm map to map our data over to the tangent space taken at q by
rst performing a change of co-ordinate system as in (3.28) such that r is set to
be the reference or identity orientation. We obtain our tangent mapped quaternion
47
trajectories V(t) = (v
1
(t), . . . , v
N
(t)) where v
i
(t) consists of (v
i1
, . . . , v
in
i
) and v
ij
=
logmap(r
ij
) for i = 1, . . . , N and j = 1, . . . , n
i
.
Following the blueprint for the univariate case we next approximate each trivariate
tangent vector trajectory using m cubic B-spline basis functions to obtain:
(3.48) v
i
(t)
m
k=1
p
ik
k
(t).
By (3.37) we see that this unfortunately results in a matrix of control points P
i m3
for each trajectory due to the multivariate nature of the response. This means that we
would be converting our functional response to a matrix-variate response following
the analogy with (3.46).
To get around this problem we stack P
i
column-wise to create:
(3.49) P
i
=
_
_
_
_
_
_
_
x
1
y
1
z
1
.
.
.
.
.
.
.
.
.
x
m
y
m
z
m
_
_
_
_
_
_
_
p
v
i
=
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
x
1
.
.
.
x
m
y
1
.
.
.
y
m
z
1
.
.
.
z
m
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
,
thus converting the matrix-variate P
i
to a 3m-variate vector p
v
i
. Therefore (3.45)
becomes:
(3.50) P
v
N3m
v
3m1
(t) = X
Np
B
p3m
v
3m1
(t) +
N3m
v
3m1
(t),
48
where P
v
N3m
is a matrix where the vectors p
v
i
T
make up the rows and
(3.51)
v
3m1
(t) =
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
1
(t)
.
.
.
m
(t)
1
(t)
.
.
.
m
(t)
1
(t)
.
.
.
m
(t)
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
.
Factoring out
v
3m1
(t) we get:
(3.52) P
v
N3m
= X
Np
B
p3m
+
N3m
,
which is a standard multivariate regression model just like in (3.46). We assume that
E(
i
) = 0 and the cov(
i
) =
3m3m
. The estimate of B is:
(3.53)
B = (X
T
X)
1
X
T
P
v
,
and the unbiased estimator of is:
(3.54)
=
T
N p
,
where
(3.55) = PX
B,
is our matrix of residuals.
Prediction for a new set of covariates x
new
is given by:
(3.56) v
new
(t) = x
new
B
v
(t).
49
Work needs to get this back to a predicted orientation trajectory as we will have
to undo all the pre-analysis transformations. We have to go through the following
steps:
1. Use the exponential map to map our predicted tangent vectors data back onto
S
3
.
2. Revert back to the original co-ordinate system by multiplying each of our pre-
dicted points by r.
3. Convert the predicted slerp residuals back to a real orientation trajectory. Note
that we require the start and end orientation to be either predicted or given
to us. We need to calculate either the constant speed slerp model trajectory
(3.38) or a speed-adjusted slerp model trajectory (3.40)
9
depending on what
method we used to get our slerp residuals and then reverse (3.41) to obtain our
predicted orientation trajectory q
new
(t).
It seems reasonable to use standard inference techniques of multivariate regression
(see Johnson and Wichern (2002), Rencher (2002)) for comparing nested models
and where dim() = p, dim() = q and p > q. The likelihood ratio test statistic
for testing H
versus H
is given by:
(3.57) (N p q
1
2
(3mq + 1)) log
|
|
|
|
where
=
(Np)
N
is the maximum likelihood estimator of the covariance. For N
large this statistic approximately follows a Chi-squared distribution with 3m(pq1)
d.f.
Unfortunately there is a problem with using this, as explained in Shen and Far-
9
We will need to predict an angular speed prole for this or have one provided for us.
50
away (2004).We observe that:
(3.58) log
|
|
|
|
=
3m
k=1
log
k
where
k
and
k
are the eigenvalues of
and
k
does not get smaller
as k becomes larger. Slerp residuals, by denition, are 0 at the start and end and
thus it is almost certain that the rst and last few spline control points are all going
to be pretty close to 0. This puts the majority of the interesting variability in the
middle increasing the chance we have only a small number of signicant eigenvalues.
Other options, including Wilks Lambda, the Lawley-Hotelling trace, the Bartlett-
Nanda-Pillai trace and Roys maximum root, all suer from the same problem.
Shen and Faraway (2004) propose a test similar to the usual F-test employed in
regression which applied to our model becomes:
(3.59) F =
(rss
rss
)/(p q)
rss
/(N p)
tr(
)/(p q)
tr(
)/(N p)
,
whose null distribution can be approximated to an ordinary F distribution with
degrees of freedom:
(3.60) f
1
=
tr(
)
2
tr((
)
2
)
(p q) and f
2
=
tr(
)
2
tr((
)
2
)
(N p).
If we do, indeed, observe that we only have a small number of signicant eigenvalues
then we recommend using this improved testing method which is robust to the choice
of m for our analysis.
Goodness of t is dicult to assess in our model. We can calculate 3m R
2
s for
each of our spline control points but this only measures the t of our model to our
tangent-mapped, speed-adjusted, slerp residual spline data and not with the actual
51
local quaternion trajectory. We would like to measure the model error with respect
to the entire process tangent mapping, spline tting and linear modeling.
The best way to tackle this would be to convert our tted values from our regres-
sion model all the way back to a real trajectory. We can then calculate point-wise a
choice of mean, median or maximal dierences between our tted trajectory and our
observed one and then average it over all trajectories. We can then use the speed-
adjusted slerp model as a yardstick to see how well our model ts the data. Wang
(2006) proposes using dynamic time warping techniques to help remove any dier-
ences due to a timing element that might be involved. This algorithm has seen use in
applications such as voice recognition software and can be represented as an iterative
equation:
DTW(Q
N
, R
M
) = dist (q
N
, r
M
) + min
_
_
DTW(Q
N1
, R
M
)
DTW(Q
N
, R
M1
)
DTW(Q
N1
, R
M1
)
(3.61)
where Q = q
1
, . . . , q
N
is a trajectory up to the Nth frame and Q = q
1
, . . . , q
N
is the
other trajectory up to the Mth frame. We use our angle of rotation distance metric
as our dist() function.
3.4 The Constraint Approach
The Tangent Mapping approach described in the previous section uses a localized
linear approximation of S
3
. In exchange for computational and mathematical sim-
plicity we lose some accuracy, the extent of which depends on the variability existing
in our data. With the Constraint approach we seek to model and analyze directly
on S
3
by treating it as a constrained subspace of IR
4
.
Non-linearity of S
3
is the biggest problem; in the tangent mapping approach we
52
could t linear models that allowed us to easily relate our scalar covariates with our
linearized response. In the constraint approach this is not possible and we need to
nd another way to model the relationship.
3.4.1 Distribution Theory on S
3
The Bingham distribution (see Bingham (1974)) was introduced to model axial
data, that is data where x and x are indistinguishable. For such data, distributions
must be antipodally symmetric i.e. f(x) = f(x). As stated previously, quater-
nions represent rotations in IR
3
uniquely up to a sign change and so the Bingham
distribution seems a natural t to model quaternion data (see Prentice (1986)).
Let q be a random unit quaternion from a Bingham distribution denoted B
4
(L, A),
then it has the Bingham density
(3.62) f(q; L, A) = {
1
F
1
(
1
2
, 2, L)}
1
exp{tr(LAqq
A
T
)}[dq],
where [dq] represents the uniform distribution on S
3
,
1
F
1
(
1
2
, 2, L) is a normalizing
constant
10
, A SO(4) and L = diag(l
1
, l
2
, l
3
, l
4
) with l
1
> l
2
> l
3
> l
4
.
The parameters l
1
, . . . , l
4
determine the relative shape of the distribution. If
l
1
+ l
4
> l
2
+ l
3
then q is said to have a bipolar Bingham distribution where the
probability mass is concentrated at opposite ends of the hypersphere. If l
1
+ l
4
<
l
2
+ l
3
then q is said to have an equatorial or girdle Bingham distribution where
the probability mass is clustered around a great circle. The Watson distribution
(see Watson (1983)) is a special case of the Bingham where the density exhibits
rotational symmetry about an axis
11
.
One can also show a close relationship between the Bingham and the multivariate
normal distribution. If q has an N
4
(0, ) then the conditional distribution of q given
10
1
F
1
is the hypergeometric function of matrix argument, see Gupta and Nagar (2000)
11
l
1
> l
2
= l
3
= l
4
leads to a bipolar Watson and l
1
= l
2
= l
3
> l
4
leads to an equatorial Watson
53
that q = 1 is Bingham with ALA
T
=
1
2
1
.
Maximum likelihood estimation revolves around the moment of inertia matrix
T =
1
n
n
i=1
q
i
q
i
and its eigendecomposition T =
A
A
T
where the MLE of A is
given by
A and the MLE of the elements of L are functionally related to the elements
of
.
Prentice (1986) proves that if X = (x)
12
then X has a matrix Von-Mises Fisher
distribution
13
if and only if x has a Bingham distribution. From this it can be shown
that
Mthe MLE for the modal matrix Mof the matrix Von-Mises Fisher distribution
is related to m = a
1
, the eigenvector corresponding to the largest eigenvalue of T by
M = ( m).
Sampling distributions for the Bingham are highly intractable mostly due to the
complexity of the normalizing constant and thus simpler asymptotic results are im-
portant. Most basic and important among these is the fact that for highly concen-
trated populations one can use normal approximations in the tangent spaces to S
3
(see Mardia and Jupp (2000), Rancourt et al. (2000)) which provides some legitimacy
for the tangent mapping approach. Other asymptotic results based on increasing di-
mensionality exist but are not of interest to us as we are interested only in quaternion
data, which has 4 dimensions.
3.4.2 Interpolation and Smoothing on S
3
The slerp introduced in section 3.3.4 is native to S
3
but not useful when we
have three or more points to interpolate. There has been quite a lot of work in
interpolation algorithms for quaternions in the computer animation eld and they
can be divided into three main approaches:
12
See appendix for this quaternion to matrix conversion.
13
A probability distribution for rotation matrices, see Khatri and Mardia (1977).
54
1. Geometric Transliteration
2. Arc Blend
3. Dierential Equation
The geometric transliteration approach treats the geodesic great circle arc of the slerp
as the equivalent of a line segment and then interprets geometric constructions in
terms of it (see Schlag (1991)). The arc blend approach combines small arc segments
to get a smooth curve and is the cheapest to compute (see Wang and Joe (1993)). The
dierential equation approach notes that natural cubic splines minimize acceleration,
and impose the spherical constraint so as to create a calculus of variations problem
which produces an Euler-Lagrange ordinary dierential equation formulation with
constraints (see Barr et al. (1992)).
Statisticians have also looked at developing spline techniques for general spherical
data as it is an important component of directional statistics. Much of the early
work was done by Thompson and Clark (1981) and Fisher and Lewis (1985).
As stated before in section 3.3.4, we are more interested in approximating our
trajectory rather than interpolating it and therefore we would like to develop a
S
3
analog of the regression splines we t for our tangent mapped trajectories. In
section 3.2 we discussed theminimum distance approach to calculating the mean
quaternion. Buss and Fillmore (2001) introduced a more generalized method that
allows calculation of a weighted average. They went on further to dene a spherical
spline function that made use of this method.
Suppose that q(t) is the quaternion trajectory we are trying to approximate. The
spherical B-spline function is dened as
(3.63)
m
j=1
p
j
j
(t),
55
where the p
j
s are the quaternion control points and the
j
(t)s are cubic B-spline
basis functions. The
n
i=1
w
i
q
i
= arg min
qS
3
n
i=1
w
i
arccos |q
i
q|,
where w
i
are the weights such that
n
i=1
w
i
= 1.
Instead of the integrated square error we have in (3.34) we wish to choose p
j
s
S
3
such that we minimize the integrated angle of rotation error i.e.
(3.65) (t) =
_
1
0
arccos
q(t)
m
j=1
p
j
j
(t)
dt.
Since we observe our trajectory as a nite series of n postures q
1
, . . . , q
n
the above
can be approximated by:
(3.66) =
n
i=1
arccos
_
q
i
m
j=1
p
j
ij
_
2
,
where |p
j
| = 1 for j = 1, . . . , m and the absolute value replaced by a square function.
Thus we are faced with a complicated non-linear constrained optimization prob-
lem. The weighted average can only be found using an iterative algorithm. Algo-
rithms such as the Augmented Lagrange Multiplier (ALM) and Sequential Quadratic
Programming (SQP) are viable options and one can code simple versions of these
with some eort. Notice also that rst and second derivatives cannot be found ex-
plicitly, making the process even more cumbersome. It is vital to have a good initial
estimate of the control points to lessen the likelihood of the algorithm getting stuck
in a local minimum.
In practice the methods described in section 3.3.4 produce decent ts to the data
and the approach set out here may not be worth the computational time and hassle.
We can, therefore, perform the spline tting in tangent space then map the spline
56
control points back onto S
3
. Since this is a tangent mapping technique it has the
usual treade-o of accuracy for simplicity and speed.
3.4.3 Regression Models on S
3
Regression analysis for spherical data, i.e., data from S
p
(The surface of a p + 1
dimensional hypersphere) was developed by Chang (1986) to analyze the motion of
tectonic plates (also known as continental drift) on the Earth surface. For certain
points u
i
there exist estimates v
i
of their past position(which have some associated
error) and the task is to nd the rotation that links them. In mathematical terms
u
i
are xed points (the predictor) on S
2
, v
i
are independent random points (the
response) such that v
i
given u
i
has density g(v
i
Au
i
) with respect to the uniform
measure on S
2
. The task is to estimate the rotation matrix A.
Prentice (1989) applied a modication of this analysis technique to orientation
data such that the u
i
and v
i
are quaternions instead of directional data on S
2
.
Each v
i
is considered to be the product of a transformation given by A
T
1
u
i
A
2
where
A
1
, A
2
SO(4). This model is for matched pairs of orientations with v
i
is considered
as the response and u
i
as the predictor. We, however, require a model where our
predictors are scalar and so this appraoch is not useful for our purposes.
Rivest developed two statistical methods for analysing orientation data, both of
which were applied to human motion experiments. The rst (see Rancourt et al.
(2000)) is a one-way ANOVA-style model for comparing terminal posture data be-
tween six dierent task locations. The second (see Rivest (2001)) method seeks to
t a xed-axis model to a single orientation trajectory. The rst model is of more
interest to us as it allows modeling of a quaternion response with a single categorical
variable. We use this as inspiration for our model which we present next.
57
3.4.4 The Quaternion ANOVA model QANOVA
As we have stated before the major problem we have with the non-linearity of S
3
is that there is no simple arithmetic operation between a scalar and a quaternion that
will keep the result on S
3
. In fact, if we go back to chapter two, the only operation
that produces a unit quaternion is the quaternion product of unit quaternions.
In section 3.3.5 we developed the concept of slerp residuals in which we interpreted
them as the dierence between the observed orientation and the slerp predicted
orientation and dened it as (3.41). Inherent in this formulation is the idea that
we can consider multiplication of one quaternion with the conjugate of another as
an analogue of subtraction in linear space. By the same token we can consider a
straight multiplication with no conjugates involved as an analogue of addition. In
other words:
x
1
+x
2
q
2
q
1
(3.67)
x
1
x
2
q
2
q
1
. (3.68)
Non-commutativity of the quaternion product is again an issue and thus we are
presented with a choice of ordering. The particular ordering above represents the
fact that when we use multiple quaternions to rotate vectors, we do the operation
right to left as seen in (2.42).
Analysis of variance or ANOVA has been a basic and fundamental technique
that has been available to statisticians since R.A. Fisher, the father of statistics,
introduced it in 1918. With the processing power of modern day computers, the
estimation and tting of the model is handled automatically and eciently using
matrix algebra techniques. We sometimes forget that all the parameters in ANOVA
can be estimated using means. Older books on ANOVA such as the one by Schee
58
(1959) show us how to estimate parameters for main-eects and interactions using
conditional means. For example, in a two-way ANOVA with interaction we can
dene the model as:
(3.69) y
ijk
=
ij
+
ijk
where i = 1, . . . , I, j = 1, . . . , J, k = 1, . . . , K,
14
ij
= E(y
ijk
) and
ijk
are indepen-
dently N(0,
2
). This
ij
, which can be interpreted as the true mean response at the
ith level of A and the jth level of B, can then be further split into
(3.70)
ij
= +
i
+
j
+
ij
,
where
1. is the overall mean of the response.
2.
i
the main eect of the ith level of factor A.
3.
j
is the main eect of the jth level of factor B.
4.
ij
is the interaction of the ith level of A with the jth level of B.
subject to the following constraints
15
:
i
= 0, (3.71)
j
= 0, (3.72)
ij
= 0 for all j, (3.73)
ij
= 0 for all i. (3.74)
14
Factor A has I levels; factor B has J levels and each cell has an equal number of replicates given by K.
15
Otherwise the least squares estimates will not be unique.
59
Therefore we have that
=
..
, (3.75)
i
=
i.
..
, (3.76)
j
=
.j
..
, (3.77)
ij
=
ij
i.
.j
+
..
, (3.78)
where
..
=
ij
ij
I J
(3.79)
i.
=
j
ij
J
(3.80)
.j
=
ij
I
. (3.81)
The least squares estimate of these parameters are the sample counterparts of the
s and thus the ability to calculate sample means is all that is required for estimation
in an ANOVA model.
We know how to calculate sample means of quaternions (see section 3.2) and
combining this with the notion that quaternion multiplication acts as addition and
subtraction on S
3
we have an analogue of the ANOVA for quaternions. We coin this
as the QANOVA. To illustrate this, we describe the two-way QANOVA model as a
comparison to the two-way ANOVA shown above. Let us dene the model as:
(3.82) q
ijk
=
ij
ijk
where
ij
= E(q
ijk
) and
ijk
are independent and identically distributed centered
at the identity. We can then decompose the
ij
into the following:
(3.83)
ij
=
ij
j
i
,
where
60
1.
ij
is the true mean quaternion at level i of factor A and level j of factor B
the cell mean.
2. is the overall mean quaternion.
3.
i
the main rotational eect of the ith level of factor A. We interpret this as
the excess rotational eect caused by the presence of the ith level of factor A
upon the overall mean quaternion.
4.
j
is the main rotational eect of the jth level of factor B.
5.
ij
is the rotational interaction of the ith level of A with the jth level of B.
The interpretation of this interaction is basically similar to that for standard
ANOVA but modied by the fact that the eect is rotational.
Keeping in mind the inherent non-commutativity of this and given the particular
order of terms in (3.83), one possible denition for the parameters is the following:
=
..
, (3.84)
i
=
i.
..
, (3.85)
j
=
..
.j
, (3.86)
ij
=
ij
i.
.j
..
, (3.87)
subject to the following constraints:
i
= 0, (3.88)
j
= 0, (3.89)
ij
= 0 for all j, (3.90)
ij
= 0 for all i. (3.91)
61
We see that all the parameters are unit quaternions, i.e., , , , S
3
as the
s are basically means that we would estimate using their sample counterparts. We
dened the parameters above in a particular order such that we have cancellation of
terms, i.e., each term will cancel out with each conjugate if it exists. This cancellation
is needed for equation 3.83 to hold true. The non-commutativity of the quaternion
product implies again that our estimates will change if we switch the order of the
terms.
Inference can be performed using the angle of rotation metric as a test statistic.
Suppose we wish to compare nested models and where dim() > dim(). The
test statistic is then given by
(3.92) t =
n
i=1
arccos
_
_
q
i
q
i
_
_
n
which represents the mean angular distance between the orientation produced by the
t with that of the t over all the observations. We would reject the or null
model if our test statistic is larger than some critical value. We use a permutation
test procedure to nd a critical value at which the size of the test is . By randomly
permuting the assignment of the factors of interest (those that are in but not in
), and tting our null and alternative QANOVA models each time, we obtain the
null distribution of our test statistic conditioned on the values of . We then
assign the critical value to be the (1 ) quantile of this permutation distribution.
We can extend the QANOVA model to a functional one in a relatively straight-
forward manner. By using the techniques laid out in section 3.4.2 we obtain the
quaternion spline coecients. We then t identical QANOVA models to all m co-
ecients to get estimates of the mean quaternion spline function for each factor
combination. This is analogous to the functional regression models we t in the tan-
gent mapping approach. Inference is done by replacing the angle of rotation metric
62
with the DTW metric (3.61) in our test statistic formulation. Thus (3.92) becomes
(3.93) t =
n
i=1
DTW
_
i
,
Q
i
_
n
where
Q
i
is the tted trajectory under the alternative model and
Q
i
is that under
the null model. These tted trajectories are obtained by converting the tted spline
coecients back to data.
Obviously these methods require us to have categorical predictors and we would
need tofactorize any that are continuous. This in turn produces prediction inter-
polation issues and thus the technique is more useful as an inference tool rather than
as a prediction model.
3.4.5 Simulated Power Study
As we have stated throughout the previous subsection the ordering of the QANOVA
terms aects our estimates. We would like to compare the power of the functional
QANOVA test for dierent orderings of the model terms. Simulation studies were
conducted based on a subset of the experimental data presented in chapter four. A
detailed description of the experiment and data is found in section 4.1.2.
Briey, the experiment involved subjects making reaches to an array of targets
and gripping a wooden block. The data we chose for this simulation study was for
reaches made to one of these blocks. There are four possible ways to grip this block
and we want to see if there is a signicant grip eect. We have 104 observations
in this particular subset of the data.
We need to simulate the response quaternion spline coecients, and we do this
by taking the following steps:
1. Fit a mean-only model using our functional regression model in the tangent
mapping approach. We then obtain the tted spline coecients from this model.
63
2. Fit another model with the factor grip. We again obtain the tted spline
coecients for this alternative model. We also calculate the estimated 3m3m
covariance matrix,
from our residuals.
3. Generate independent 3m variate Gaussian error terms that have mean 0 and
covariance
.
4. Add this error to both the mean-only model coecients as well as to the model
with the grip factor.
5. Convert these tangent mapped spline coecients back to quaternions using the
exponential map.
6. Take a weighted spherical average of the mean-only model spline coecients
with that of the grip model spline coecients using the slerp algorithm. The
weight, , runs from 0 (which produces the null t) to 1 (which produces the
alternative t).
Thus we set the value of our nuisance parameter, which is the overall mean, as the
tted mean from the mean-only model.
For each set of simulated data, we t the null functional QANOVA model such
that the tted value of the uth quaternion spline coecient at the ith level of the
grip factor is given by
(3.94)
u
q
i
=
u
=
u
.
.
There are only two possible orderings of the terms for the alternative model in this
simple case; the rst is
(3.95)
u
q
i
=
u
u
i
=
u
.
u
.
u
i
64
0 0.2 0.4 0.6 0.8 1
0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1
theta
p
o
w
e
r
Power Plots
Order 1
Order 2
Lik ratio
Figure 3.6: Plots of power versus for the one-way functional QANOVA simulation study. We have
two curves for the two dierent term orderings and a curve for the likelihood ratio test.
and the second is
(3.96)
u
q
i
=
u
i
u
=
u
.
u
i
u
.
We conducted the DTW based tests on both orderings and either accepted or rejected
the null model. We calculated the proportion of times we rejected the null out of the
2000 trials and plotted these versus (see gure 3.6). When is zero this proportion
gives us the size and for all other it gives us the power. We used the permutation
critical values for the DTW test (for each ordering) as well as the likelihood ratio test
so that we could set the size for all the tests to be exactly 0.05. We see that for this
simple univariate case the dierent ordering has no eect on the power. We also used
the likelihood ratio test from the functional regression tangent-mapping approach.
There appears to be very little dierence between the methods with perhaps a slightly
lower power for the likelihood ratio test when is between 0.1 and 0.6.
We conducted another study on a more complex problem to see if there was a
signicant pod eect in the presence of a block and grip eect. Using the
65
same process as before, we have the null functional QANOVA tted value of the uth
quaternions spline coecient at the ith level of pod (), the jth level of block
() and the kth level of grip (), to be
u
q
ijk
=
u
k
u
j
u
(3.97)
=
u
...
u
..k
u
...
u
.j.
u
...
. (3.98)
We then looked at three dierent orderings for the alternative ts. The rst two
have the pod eect term added either at the front of the null model ordering or at
the end which is an analagous case to the the simple one-way study we did before.
This gives us
u
q
ijk
=
u
i
u
k
u
j
u
(3.99)
=
u
...
u
i..
...
u
..k
u
...
u
.j.
u
...
, (3.100)
and
u
q
ijk
=
u
k
u
j
u
u
i
(3.101)
=
u
...
u
..k
u
...
u
.j.
u
...
u
...
u
i..
. (3.102)
The last one was a completely dierent ordering given by
u
q
ijk
=
u
j
u
u
i
u
k
(3.103)
=
u
...
u
.j.
u
...
u
...
u
i..
...
u
..k
. (3.104)
The power curve plot in gure 3.7 was then obtained again with the likelihood
ratio test given as a comparison. We see that the power level for the rst two
orderings are almost the same, as expected, while the nal ordering produces a much
higher power. All three QANOVA methods are more powerful than the likelihood
ratio test.
66
0 0.2 0.4 0.6 0.8 1
0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1
theta
p
o
w
e
r
Power Plots
Order 1
Order 2
Order 3
Lik ratio
Figure 3.7: Plots of power versus for the second simuation study. We have three curves for the
dierent QANOVA term orderings and one for the likelihood ratio test.
In the simple case of one-way QANOVA the two orderings have little eect on the
power but it does make a dierence for the more complicated scenario. The more
terms we have in the model the exponentially greater the possible orderings become
and thus more dicult to assess which ordering will provide the greatest power.
We still need to discover, rst of all, why there is such a discrepancy and whether
there is a systematic method for guring out which ordering produces the highest
power. Simulation studies of higher order layouts and an exhaustive comparison of
all possible orderings, although time consuming, may be the only way of nding the
optimal order. For readers who are interested in recreating these graphs please send
an e-mail to choes@umich.edu.
Critical values for the QANOVA tests need to be obtained using the permutation
procedure. For main eects this process is simple, but if we wish to test the presence
of interaction eects, it is not so obvious. We need to nd a way of adapting the
permutation method for such situations possibly using a Latin Squares approach.
CHAPTER IV
Application
4.1 An Orientation Trajectory Model for the Right Hand in Unladen
Reaches
In this section we apply the techniques set out in the previous chapter and describe
a model for the right hand that forms part of the HUMOSIM full-body motion
prediction model. This application was the main impetus for my research.
4.1.1 Purpose of Model
The purpose of our model is to predict an orientation trajectory for the right hand
during reaching motions. The hand is considered the end eector in this case and is
not holding any sort of object. The user of this model will provide the starting and
ending location and orientation of the hand (we envision a graphical interface where
the end-user places target hand prints see gure 4.1) as well as information
about the human gure such as age, sex and anthropometry.
4.1.2 Description of Experiment
The data with which the model was built are from an experiment conducted at
the HUMOSIM laboratory in the summer of 2000. The purpose of the experiment
was to assess how the terminal hand orientation aected the entire body posture
during seated motions. Experimental xtures were built wherein a subject would
67
68
Figure 4.1: Illustration of how the user will place target hand-prints for the human model to
reach to.
69
reach to an object placed in dierent locations and grasp it with the hand in several
rotated orientations.
The experiment task was implemented by presenting a set of ve standard grip
blocks clustered on the faces of a cube array. The cube was constructed with each
side face turned 20 degrees to the front to enhance visibility and to tighten the
cluster of blocks. Each cluster or pod represented a spatial locality and each of the
ve near faces of the array represented a direction eect. Four hand orientations
for gripping dierent edges of the ve blocks provided an orientation eect. The
edges of the grip blocks were color-coded: Top was green, right was red, bottom
was blue, and left was yellow. Three clusters were stacked and supported from
a post (tower) that was repositioned with respect to the subject to provide four
lateral locations. Figure 4.2 illustrates this experimental setup. This created a
total of 4(tower) 3(pod) 5(block) 4(grip) = 240 possible location/orientation
combinations for the hand of which 210 were deemed reachable. Thus the entire
dataset consisted of 4410 trials.
Twenty subjects were selected to distribute age, sex and height. Table 4.1 shows
a breakdown of these subjects.
A combination of two systems were used for motion-capture: a six-camera MacRe-
ex optical tracking system and a ve-sensor Flock of Birds electromagnetic sys-
tem. Since these were seated reaches, subjects were outtted with sensors only from
the hip and above. Figure 4.3 shows placement of the sensors. Using a combina-
tion of this motion-capture data and detailed anthropometric measurements taken
from the subjects, the x-y-z coordinate trajectories for each marker location in the
HUMOSIM linkage system (see gure 4.4) were calculated.
All subjects began their reach motions from a home position with the right hand
70
(a) Cluster of Grip Blocks (b) Individual Tower
(c) Lateral Arrangement of Tower
Figure 4.2: Illustration of experiment setup. (a) Each cluster consists of ve blocks. The blocks were
color-coded and the subject was asked to grip the block with the thumb on a selected
color side. (b)Three clusters were placed at dierent heights on a tower. (c)The tower
was then placed in four positions: 45
to the right, 90
to the
right.
71
(a) Front
(b) Back
Figure 4.3: Illustration of placement of optical markers (shown as circles) and electromagnetic sen-
sors (shown as squares) on a subject
72
Figure 4.4: Illustration of the marker positions for the HUMOSIM linkage system. For our experi-
ment we will not have any of the markers below the hip.
73
Table 4.1: Anthropometry of subjects in Terminal Hand Orientation and Eort Reach Study, 2000
Subject M/F Age Weight Height
(yrs) (kg) (cm)
1 M 20 60.9 173.8
2 F 21 67.1 163.1
3 M 22 81.4 185.5
4 F 21 43.6 150.0
5 F 48 61.0 169.9
6 M 33 81.1 176.5
7 M 68 76.8 190.5
8 F 48 67.3 163.9
9 F 70 56.4 151.6
10 F 52 76.6 149.6
11 F 34 59.4 164.3
12 F 54 59.3 160.5
13 M 68 95.1 173.3
14 M 44 87.3 171.3
15 M 49 64.3 166.1
16 M 48 70.5 174.6
17 F 54 58.0 160.6
18 M 35 81.0 186.1
19 M 53 86.0 170.1
20 F 29 87.4 170.1
resting on the right thigh. Subjects also had to push or pull the block after gripping
it but we decided not to dierentiate between this as the purpose of our model was
to predict reaching tasks
1
. We divided each reach into two distinct trajectories: one
for going toward the target and one for returning to the home position, giving us
a total of 8820 motions. We t separate models for each: the Go model and the
Return model.
4.1.3 Data Preparation and Fitting of the Speed-Adjusted Slerp Residual Functional
Regression Model
We calculated the local orientation trajectory of the right hand with respect to
the right forearm using the techniques laid out in section 3.1. The rst step for this
was to obtain the rotation matrices with respect to the global coordinate system
1
Analysis seemed to indicate that there was no siginicant dierence
74
for both the hand and the forearm. Using the marker nomenclature in gure 4.4
2
,
the basis vectors that form the rotation matrices columns are given as, rst for the
hand:
x
hand
=
(rgrip rwrist)
(rgrip rwrist)
, (4.1)
y
hand
=
(rhand rwrist) (rgrip rwrist)
(rhand rwrist) (rgrip rwrist)
, (4.2)
z
hand
=
x
hand
y
hand
x
hand
y
hand
. (4.3)
and then for the forearm:
x
forearm
=
(rwrist relbo)
(rwrist relbo)
, (4.4)
z
forearm
=
(rwrist relbo) (rshoul relbo)
(rwrist relbo) (rshoul relbo)
, (4.5)
y
forearm
=
z
forearm
x
forearm
z
forearm
x
forearm
, (4.6)
where represents the cross product. Using this method of calculation, we dene the
identity or reference orientation of the hand to be aligned with the forearm and have
the palm facing downwards. We shall call this the neutral orientation; see gure
4.4. We discovered though that there were instances of instability in the forearm
orientation due to problems with z
forearm
. This basis vector is calculated as the
normal vector to the plane formed by the forearm and the upper arm. When the arm
is bent at the elbow this plane is well-dened but when the arm is straight the forearm
and the upper arm is aligned and the plane collapses causing the cross-product to
become unstable. With no alternative way to obtain the forearm orientation the
data for such cases had to be dropped. There were additional problems that included
coincident and missing marker positions. All told, the amount of motions that were
2
rshoul, relbo and rwrist are the joint center locations (which are derived) of the right shoulder, elbow and wrist,
respectively. rhand is the location of the electromagnetic marker placed of the back of the right hand. rgrip is a
derived location that represents the grip center or the middle of the palm
75
Figure 4.5: Handplot of the neutral orientation. The conical cylinder shows the forearm aligned
parallel to the x-axis. The hand is, in turn, aligned to the fore arm with the palm facing
downwards.
used to produce each model was 3071 for the Go model and 3096 for the Return
model.
Using the appropriate conversion algorithm (see appendix) these rotation matri-
ces were converted into global quaternions for the hand and the forearm. The local
quaternion trajectory for the hand was then calculated from the resulting global tra-
jectories using (3.1). Depending upon the domain and range of the inverse trigono-
metric functions in the computer software, it is possible that the calculated trajec-
tories will ip between antipodes. Since we have smooth motions and each posture
is only one twentieth of a second apart we can use a simple modication of the ip
algorithm to select the antipode that is closer to the posture preceding it.
The data also needed to be cut to remove some of the frames at the beginning,
before the hand begins its rotational motion, and at the end, after the hand has
completed its rotational motion. We need to do this to get rid of this unwanted
source of variability and also to maximize the use of our cubic B-splines so that we
76
do not waste precious parameters on tting absence of motion. There unfortunately
is no denite rule on how to determine these cut points and that makes this somewhat
arbitrary. As a rst step to determining these cuts and for use in the speed-adjusted
slerp, we obtain the angular speed prole (3.39) for each of our observed trajectories.
We dene the starting cut point as the frame just before the speed prole rst exceeds
5
per second and the end cut point as the frame just after the speed prole last falls
below 5
per second.
Comparing our rotational cut points with the translational cut points obtained
by Wang (2006), it appears that the hand starts to rotate before translational motion
begins and nish after translation ends. Histograms of the dierence between the cut
points are shown in gure 4.6. The dierence in the starting point is small enough
such that we can probably attribute it to the fact that we used separate methods
to cut our data but the discrepancy in the endpoint is quite large. Plots of the cut
speed proles (see gure 4.7) typically show a right skewed shape indicating that
there is a period of ne-tuning of the orientation toward the end of the motion.
We then proceeded to t our speed-adjusted slerp model to our cut local quater-
nion trajectories using (3.40) and from that, obtained our speed-adjusted slerp resid-
ual trajectories. Since all these start and end at the identity the mean quaternion
was very close to it (around 4
6.5046
Spline 10 7.0022
6.3815
Spline 12 6.9554
6.3197
Slerp 10.7696
11.0869
9.9040
9.4976
DTW dierence with the actual observed trajectory. The speed-adjusted slerp
trajectory is also shown. The frames are equally spaced in the time domain. Most of
the noticeable dierence occurs in the second and third frames.
to note that by denition, all of our tted trajectories are restricted to be the same
as the actual at the beginning and the end. To get a better idea of how much a 10
115
Slerp 11.6479
10.7139
9.8896
9.2349
.
u
i
,
86
and the second ordering as
(4.10)
u
q
i
=
u
i
u
=
u
.
u
i
u
.
,
where i has two levels push or pull. The null model is given by
(4.11)
u
q
i
=
u
=
u
.
.
We then calculated the DTW test statistic for both orderings using (3.93), ob-
taining 0.8077 and 0.8119, respectively. The next step was to use the permutation
procedure described in section 3.4.4 to obtain the null distribution of the test statis-
tic and hence the critical value. The critical values for a 5% level test of the two
orderings were obtained to be 2.0117 and 2.0036 and thus we would fail to reject the
null in both cases. This seems to suggest that, at least for this subset of the data,
that we were justied in not dierentiating between the push/pull tasks.
4.1.5 Joint Limit Estimation
In section 3.3.3 we set out a quick and simple method for estimating the range
of motion limit for a joint from data using the empirical maximum Mahalanobis
measure. In our experiment we had a wide range of orientations for the right hand
including many that were on or close to the limit. The terminal local orientations
of the hand could potentially be used as data for estimating the joint limit. Unofor-
tunately, we cannot assume that this data follows the required assumption, namely,
that we have a random sample from the joint limit boundary.
There were two potential problems that we faced because of this:
1. The terminal orientations we have were produced, not as a random sampling
of possible hand orientations, but as a result of the layout of the targets per
our experimental design. Thus there is a possible bias in our estimate of the
87
covariance matrix which would aect the general shape of the ellipsoid the
directions of the three principal axes and the ratio of the three radii.
2. Using the maximal Mahalanobis distance makes our limit sensitive to data prob-
lems. Outliers caused by faulty data would not only aect the shape of the el-
lipsoid but also result in us perhaps choosing too large an isoprobability contour
and thus overestimating our joint limit.
The rst problem is dicult to solve. One way to reduce the bias is if we remove
the interior points and keep only those that form the convex hull of our tangent
mapped terminal orientations. This way we remove nearly all of the potential bias
sources and weight each of the exterior extreme orientations equally. The second
problem is easier to handle. Instead of using the maximum sample mahalanobis
distance we could use the ninety-fth percentile. We could also use a more complex
robust covariance estimate such as that produced by the nearest neighbour variance
estimation method developed by Wang and Raftery (2002).
We used the tangent vectors of the target local orientations taken at the identity
Expx, Expy and Expz which we already calculated as a covariate for our func-
tional regression model. We then identied the convex hull of these tangent vec-
tors and used just these exterior points for our covariance estimation. We recal-
culated the quaternion mean of the convex hull points, which turned out to be
q = (0.12843, 0.064967, 0.0070096, 0.98956), such that we could recenter our
tangent gaussian. There were fty of these points and we looked at each one to
see if any had obvious faults. All were extreme but realistic orientations that were
on or close to the joint limit and thus we decided that we didnt need to use the
robust covariance estimation method or the 95th percentile mahalanobis distance.
88
We estimated the covariance matrix of our recentered fty tangent vectors to be:
=
_
_
_
_
_
_
_
0.4982 0.0598 0.0266
0.0598 0.1758 0.0263
0.0266 0.0263 0.1286
_
_
_
_
_
_
_
(4.12)
The sample mahalanobis distances for each of our vectors v
1
, . . . , v
n
is given by:
(4.13) d
Mah
(v
i
) =
_
v
T
i
1
v
i
_1
2
We then obtained the maximal distance = 2.3632 and thus the formula for our
ellipsoid is given as:
(4.14) f(x = P
T
v) =
x
2
1
0.7851
2
+
x
2
2
1.0085
2
+
x
2
3
1.6879
2
= 2.3632
2
where
(4.15) P =
_
_
_
_
_
_
_
0.1324 0.1226 0.9836
0.4715 0.8651 0.1713
0.8719 0.4864 0.0567
_
_
_
_
_
_
_
A plot of the joint limit and the data are given in gure 4.11. To assess the eec-
tiveness of the joint limit we sampled 25 points from the surface of the ellipsoid (see
gure 4.12) and produced handplots for each (see gure 4.13). Unfortunately, we can
see a few orientations that seem impossible
3
[1,4], [2,1] and [2,4], and a few that
do not seem as extreme as one would hope [3,3] and [3,4]. If the estimated limit
rsults in too many impossible orientations, we can improve upon it simply by using
a lesser empirical quantile of the Mahalanobis distances instead of the maximum.
We can easily check if a potential prediction orientation lies beyond our calculated
limit by performing three simple steps:
3
We use a matrix index-type identier, e.g. [1,2] is the plot on the rst row and second column.
89
Figure 4.11: Ellipsoidal Joint Range of Motion Limit estimated from our terminal local orientations
Figure 4.12: 25 sampled points from our Ellipsoidal Joint Range of Motion Limit
90
Figure 4.13: Handplots of the 25 sampled points from our Ellipsoidal Joint Range of Motion Limit.
Using a matrix index to identify a plot, e.g. [2,4] is the plot that is on the second row
and fourth column, we identify those that appear to be impossible [1,4], [2,1] and
[2,4], and those that appear not to be on the joint limit boundary [3,3] and [3,4]
.
91
1. Map the predicted quaternion onto the tangent space centered at q.
2. Calculate the mahalanobis distance of this point.
3. Look at the prediction more carefully if the distance is close to the limit given
by = 2.3632.
As expected the ellipsoidal shape of our isoprobability contour is too simplistic to
accurately depict the joint limit. The joint limit for the shoulder produced by Herda
et al. (2002) appears to be quite a bit more complex and it would be reasonable to
assume that this is the case for the wrist as well. Still the ellipsoid appears to be a
reasonable approximation and can be used as a quick and eective check to see if a
predicted orientation is close to the joint limit.
We can also study the variability of the joint limits by subject. If we make the
naive assumption that the shape of the limit is the same for everyone
4
, then we
can use the maximum mahalanobis distance as a simple univariate measure of how
exible or limber a particular subjects wrist is. We modeled this with respect to
the sex, age, weight and height of the subject. Only weight and sex appeared to be
signicant predictors and the relationship is illustrated in gure 4.12. Interestingly,
it appears that wrist exibility increases with weight for females while the opposite is
true for males. Our original experimental design had all twenty subjects reaching to
the same set of targets but due to data problems we had to drop some observations.
This means that we cannot really compare the limits between subjects as they were
not produced from the same collection of reach targets.
4
This assumption would exclude the possibility that some people can be more exible in a certain direction while
being simultaneously less exible in another.
92
Figure 4.14: Plot of mahalanobis distance versus weight of subject. Males are indicated by M and
females are indicated by F. The regression line for males is given by the solid line
while the one for females is given by the dashed line. It appears as if wrist exibility
increases with weight for females while the opposite holds true for males.
CHAPTER V
Discussion and Future Work
We shall now briey summarize the contributions we have made as a result of this
research:
1. The idea of tangent mapping quaternions is not new (see Grassia (1998)). Many
authors including Prentice (1989), Rancourt et al. (2000) have used this as a
tool for analysis, where the data that they modeled were concentrated enough
such that the distortion eect was minimal. Our method of using slerp residuals
allows us to use the tangent mapping approach when the data are not initially
well concentrated.
2. Previous asymptotic results for the Bingham distribution have shown that we
can approximate highly concentrated Bingham data as normally distributed on
the tangent plane. This result is presented in the literature as basically a tool
for allowing inference to be done on such data. We have presented the tan-
gent Gaussian as a legitimate distribution for orientation data with meaningful
interpretations of the parameters involved.
3. No statistical methods existed for modeling a quaternion response with scalar
predictors. Spherical regression developed by Chang (1986)) and their deviants
(see Prentice (1989), Rivest (2001)) were designed to model pairs of orienta-
93
94
tions where one was considered the response and the other the predictor. Our
quaternion functional regression and QANOVA model allows us to model entire
functions of quaternions with respect to scalar predictors. Simple procedures
based on existing multivariate data analysis techniques such as Wilks lambda
and likelihood ratio tests can then be used for inference purposes.
4. The QANOVA model is a multiplicative quaternion analog of the standard
ANOVA model. The model is designed to make inference in the presence of
categorical or factor covariates. Simulation studies have indicated that they are
favorably comparable to the asymptotic likelihood based procedured used in our
funtional regression models.
5. By application of our models to the study of human motion we have discovered
that the hand seems to basically follow a slerp trajectory during reaching tasks
and that dierences in anthropometry and target location cannot explain ap-
parent deviations from it. We have also introduced a simple way of estimating
joint range of motion limits based on an empirical Mahalanobis distance mea-
sure. These limits are not meant to be an accurate representation but rather a
quick method for checking the quality of any predictions made from our model.
One way to improve upon our functional regression method would be to use a
better curve tting procedure. The cubic B-spline approach that we have used is not
the most ecient method of approximating the slerp-residual trajectories. Much of
the action occurs in a relatively small portion of the trajectory and thus we are
wasting some of our precious parameters on relatively unimportant sections. Since
our tangent-mapped residuals are in IR
3
we could apply the modeling techniques set
out by Wang (2006). The Bezier curves use fewr parameters and might improve the
95
t.
The lack of uniqueness of the QANOVA estimates caused by the non-commutativity
of the quaternion product is a problem. The greater the number of terms there are
in the model the more variable the estimates will be. Further study needs to be done
to gure out how variable these estimates are and which order would produce the
best estimate. We also need to discover why there is such a discrepancy in the
power for dierent orderings and whether there is a systematic method for guring
out which ordering produces the highest power. Critical values for the QANOVA
tests need to be obtained using the permutation procedure as we do not have a de-
ned null distribution for the DTW test statistic. For main eects this process is
simple but if we wish to test the presence of interaction eects it is not so obvious.
We need to nd a way of adapting the permutation method for such situations.
A major weakness of our hand orientation trajectory model is that all of our data
consisted of reaches that start and end at a home position. In our Go model we
have no variability at all in our starting orientation and therefore this severely limits
the predictive ability of our model when the user species a start orientation that
is far from neutral. This is true for our Return model which has no variability in
the nal orientation. An ad-hoc blending approach that combined a prediction from
the Go model with one from the Return model was implemented for predictions
where the initial and target hand orientations were far from neutral. This blending
approach would naturally introduce a tendency toward a neutral orientation in the
middle of the trajectory. Suppose that we have a subject that starts at an awkward
orientation and reaches to a target that is spatially distant but requiring a similarly
awkward posture. If a simple slerp trajectory was t then we would have the subject
maintaining that awkward posture of the hand throughout the course of the reach.
96
By creating a weighted blend between the slerp model and the combination of the
Go and Return model
1
we can control the amount by which the tendency to
neutral occurs. Still, the absence of real data makes this approach mere conjecture.
We still do not have a viable way of obtaining condence regions for our predicted
trajectories. Point-wise intervals as used in Faraway (2000) might be viable for
univariate trajectories but not for our trivariate tangent vector trajectories, let alone
our quaternions trajectories. In the regression model we are predicting the spline
control point values and, assuming each is trivariate normal, we expect the condence
region for each control point to be an ellipsoid. It is dicult to imagine or represent
how the spline curve will change if we vary each control point within its condence
ellipsoid.
Ultimately we need to combine the orientation trajectory model we have with
the translational aspect of the motion to produce a complete six degree of freedom
prediction model for the hand. Our work and that of Wang (2006) will be combined
along with other parts of the HUMOSIM framework to create a full gure motion
prediction model. We conclude with an illustration (see gure 5.1) of a combined
predicted trajectory of the right hand reaching to the bottom block of the lower pod
on the tower placed 45
to the left.
1
actually applied the other way round as the Return model predicts a trajectory that starts at a non-neutral
orientation and ends at the neutral and the Go model is the other way around.
97
Figure 5.1: Combined reach trajectory predicted by our model to a target from the HUMOSIM
experiment.
APPENDICES
98
99
APPENDICES
The rst section of the appendix will cover algorithms that we can use to con-
vert between the various rotation parameterizations. There are numerous reasons
we would wish to do this. We have already seen that the easiest way to obtain the
orientation of an object from landmark location data is to form rotation matrices.
Therefore we would need to convert these matrices to quaternions to continue with
our analysis. The Euler angle representation can be used to better interpret our
results. In an analysis conducted on torso motion of people with spinal cord injuries
and lower back pain we converted predicted orientation trajectories into Euler an-
gles such that we can better assess and interpret the eects of these problems by
decomposing them to sagittal, transverse and axial motion.
The second section will explain how we obtained the spline design matrix or
matrix in (3.33). The matrix is made up of the spline basis functions and can be
considered as the model matrix in a regression setting.
Conversion Algorithms
A great reference and the source of the algorithms shown here is Baker (2006).
We will list only those conversions related to the quaternion parameterization:
1. Rotation matrix quaternions.
2. Euler angles quaternions.
100
Rotation Matrix Quaternions
Suppose we have a unit quaternion q = (x, y, z, w) written as a four vector. Then
the matrix form of the rotation represented by q is given as:
(q) =
_
_
_
_
_
_
_
1 2y
2
2xy 2zw 2xz + 2yw
2xy + 2zw 1 2x
2
2z
2
2yz 2xw
2xz 2yw 2yz + 2xw 1 2x
2
2y
2
_
_
_
_
_
_
_
.
The above equation is true if we replace q by its antipode q.
The backward conversion can vary in diculty depending on whether or not the
matrix is exactly special orthogonal i.e. SO(3). Rounding errors, in particular, could
have occurred during its synthesis and would result in the matrix not being exactly
SO(3). Suppose we have a rotation matrix,
M =
_
_
_
_
_
_
_
m
11
m
12
m
13
m
21
m
22
m
23
m
31
m
32
m
33
_
_
_
_
_
_
_
,
that we wish to convert to a quaternion, q = (x, y, z, w). The algorithm goes as
follows:
1. If
1+m
11
+m
22
+m
33
4
> 0 then
(a) w =
_
1+m
11
+m
22
+m
33
4
,
(b) x =
m
23
m
32
4w
,
(c) y =
m
31
m
13
4w
,
(d) z =
m
12
=m
21
4w
,
2. else w = 0 and if
m
22
m
33
2
> 0 then
(a) x =
_
m
22
m33
2
,
101
(b) y =
m
12
2x
,
(c) z =
m
13
2x
,
3. else x = 0 and if
1m
33
2
> 0 then
(a) y =
_
1m
33
2
,
(b) z =
m
23
2y
,
4. else y = 0 and z = 0.
Euler Angles Quaternions
As mentioned before Euler angles are dened by their order and thus our conver-
sion algorithms depend on this. Let us assume that we are using the XY Z ordering
for the Euler angles and dene the angles as a triple (, , ). If we wish to convert
this particular denition of Euler angles to a quaternion, q = (x, y, z, w), we have:
1. w = cos
2
cos
2
cos
2
+ sin
2
sin
2
sin
2
,
2. x = cos
2
cos
2
sin
2
sin
2
sin
2
cos
2
,
3. y = cos
2
sin
2
cos
2
+ sin
2
cos
2
sin
2
,
4. z = sin
2
cos
2
cos
2
cos
2
cos
2
sin
2
.
For the quaternion to Euler angles conversion we have:
1. = arctan
2xy+2wz
12y
2
2w
2
,
2. = arcsin(2xz + 2wy),
3. = arctan
2xw+2yz
12x
2
2y
2
.
102
Spline Design Matrix
Suppose that we observe y
1
, . . . , y
n
from a function y(t) at equally spaced time
points t
1
, . . . , t
n
which is rescaled such that t
1
= 0 and t
n
= 1. We wish to t
a regression spline to this data using m B-spline basis functions of degree p. For
i = 1, . . . , m, the basis functions can be dened as:
B
i,1
(t) =
_
_
1 if k
i
t < k
i+1
0 otherwise
B
i,p+1
(t) =
t k
i
k
i+p
k
i
B
i,p
(t) +
k
i+p+1
t
k
i+p+1
k
i+1
B
i+1,p
(t)
where k are known as knot points. If the function y
t
is constrained such that it starts
and ends at 0,
2
then our knot sequence is given by k
1
, . . . , k
m+p+3
where k
1
= . . . =
k
p+1
= 0 and k
m+p+3
= . . . = k
m+2
= 1. Otherwise our knot sequence is given by
k
1
, . . . , k
m+p+1
where k
1
= . . . = k
p+1
= 0 and k
m+p+1
= . . . = k
m
= 1. From (3.33)
we have that:
Y
n1
=
nm
P
m1
+
n1
.
In the unconstrained problem,
ij
, the ijth element of is given as:
ij
= B
j,p+1
(t
i
)
where i = 1, . . . , n and j = 1, . . . , m. For the constrained problem we rst make a
matrix with two extra columns
n(m+2)
. ij
ij
= B
j,p+1
(t
i
)
where i = 1, . . . , n and j = 1, . . . , m + 2. Our matrix is then just the
matrix
with the rst and last columns removed.
2
Our slerp residual data would be an example of this
BIBLIOGRAPHY
103
104
BIBLIOGRAPHY
Baker, M. (2006). www.euclideanspace.com.
Barr, A., B. Currin, S. Gabriel, and J. Hughes (1992). Smooth Interpolation of Orientations with
Angular Velocity Constraints using Quaternions. Computer Graphics, ACM Press, 313-320.
Bingham, C. (1974). An Antipodally Symmetric Distribution on the Sphere. The Annals of
Statistics, 2, 6, 1201-1225.
Buss, S. (2003). 3D Computer Graphics: A Mathematical Introduction with OpenGL. Cambridge
University Press, UK.
Buss, S. and J. Fillmore (2001). Spherical Averages and Applications to Spherical Splines and
Interpolation. ACM Transactions on Graphics, Vol. 20, No. 2, 95-126.
Chang, T. (1986). Spherical Regression. The Annals of Statistics, Vol. 14, No. 3., 907-924.
Downs, T. (1972). Orientation Statistics. Biometrika, 59, 3, 665-676.
Faraway, J. (1997). Regression Analysis for a Functional Response. Technometics, 39, 254-261.
Faraway, J. (2000). Modelling Reach Motions Using Functional Regression Analysis. SAE Tech-
nical Paper 2000-01-2175.
Fisher, N. and T. Lewis (1985). A Note on Spherical Splines. Journal of the Royal Statistical
Society, Series B(Methodological), Vol. 47, 482-488.
Goldstein, H. (1980). Classical Mechanics. Addison-Wesley, Reading, Mass.
Grassia, F. (1998). Practical Parameterization of Rotations Using the Exponential Map. The
Journal of Graphics Tools, Vol. 3.3.
Gupta, A. and D. Nagar (2000). Matrix Variate Distributions. Chapman and Hall.
Hamilton, W. (1866). Elements of Quaternions. Longmans Green & Co, London.
Herda, L., R. Urtasun, P. Fua, and A. Hanson (2002). Automatic Determination of Shoulder Joint
Limits using Quaternion Field Boundaries. Proceedings of the 5th International Conference on
Automatic Face and Gesture Recognition, IEEE Computer Society, 95-100.
Johnson, R. and D. Wichern (2002). Applied Multivariate Statistical Analysis. Prentice Hall,
New Jersey.
Jupp, P. and J. Kent (1987). Fitting Smooth Paths to Spherical Data. Applied Statistics, 36,
34-46.
Jupp, P. and K. Mardia (1989). A Unied View of the Theory of Directional Statistics, 1975-
1988. International Statistical Review, 57, 3, 261-294.
105
Khatri, C. and K. Mardia (1977). The Von-Mises Fisher Distribution in Orientation Statistics.
Journal of the Royal Statistical Society, Series B(Methodological), Vol. 39, 95-106.
Mardia, K. and P. Jupp (2000). Directional Statistics. John Wiley & Sons LTD.
Prentice, M. (1986). Orientation Statistics Without Parametric Assumptions. Journal of the
Royal Statistical Society. Series B(Methodological), Vol. 48, Issue 2, 214-222.
Prentice, M. (1987). Fitting Smooth Paths to Rotation Data. Applied Statistics, Vol. 36, Issue
3, 325-331.
Prentice, M. (1989). Spherical Regression on Matched Pairs of Orientation Statistics. Journal of
the Royal Statistical Society. Series B (Methodological), Vol. 51, No. 2, 241-248.
Ramsay, J. and B. Silverman (1997). Functional Data Analysis. Springer, New York.
Rancourt, D., L. Rivest, and J. Asselin (2000). Using Orientation Statistics to Investigate Vari-
ations in Human Kinematics. Applied Statistics, 49, 81-94.
Rencher, A. (2002). Methods of Multivariate Analysis. Wiley $ Sons, New York.
Rivest, L. (2001). A Directional Model for the Statistical Analysis of Movement in Three Dimen-
sions. Biometrika, 88, 3, 779-791.
Schee, H. (1959). The Analysis of Variance. Wiley & Sons, New York.
Schlag, J. (1991). Using Geometric Construction to Interpolate Orientations with Quaternions.
Graphics Gems II, Academic Press, 377-380.
Shen, Q. and J. Faraway (2004). An F Test for Linear Models with Functional Responses.
Statistica Sinica, Vol. 14, 1239-1257.
Shoemake, K. (1985). Animating Rotation with Quaternion Curves. ACM SIGGRAPH, Vol. 19,
No. 3.
Shoemake, K. (1987). Quaternion Calculus and Fast Animation. ACM SIGGRAPH, Course
Notes on State of the Art Image Synthesis, 101-121.
Thompson, R. and R. Clark (1981). Fitting Polar Wander Paths. Physics of the Earth and
Planetary Interiors, 27, 1-7.
Wang, J. (2006). Statistical Modeling for 3-D Trajectories. PhD Thesis, Department of Statistics,
University of Michigan.
Wang, N. and A. Raftery (2002). Robust covariance estimation via nearest neighbor cleaning.
Journal of the American Statistical Association, 97, 994-1019.
Wang, W. and B. Joe (1993). Orientation Interpolation in Quaternion Space using Spherical
Biarcs. Proceedings of Graphics Interface, pg 24-32, Morgan Kauman, San Francisco.
Watson, G. (1983). Statistics on Spheres. Wiley & Sons, New York.
Weisstein, E. (2006). mathworld.wolfram.com.
ABSTRACT
Statistical Analysis of Orientation Trajectories via Quaternions with Applications
to Human Motion
by
Su Bang Choe
Chair: Julian J. Faraway
The motion of an object in three-dimensional space can be described and mea-
sured in terms of its location and orientation. The purpose of the work presented
here is to develop statistical methods for modeling the orientation aspect of mo-
tion. The methods use the quaternion parameterization of orientation, the domain
of which is the four dimensional unit hypersphere. This advantages provided by this
parameterization are that it is compact, interpretable and free from coordinate sin-
gularities. The focus is on applying our methods to human motion analysis where
we seek to predict the orientation trajectory of a body segment during a motion task
using covariates such as anthropometry and location and orientation of the body
segment at the start and end of the motion.
There are two approaches to analyzing quaternion data: a tangent mapping ap-
proach that uses the exponential and logarithm maps to approximately linearize
1
the quaternion space and a constraint approach in which we treat the quaternion
space as a constrained subspace of IR
4
. Using the former approach, a quaternion
functional regression technique for modeling orientation trajectories is developed.
Existing regression techniques for orientation data had been limited to modeling a
single frame response with a single orientation covariate. This model allows us to re-
late a quaternion functional response with scalar predictors. A plausible probability
distribution for our tangent mapped quaternions is presented along with a quick and
simple method for estimating a joint range of motion limit from existing data. We
also introduce the concept of slerp residuals that provide a way of reducing the error
inherent in the tangent mapping process. Finally, using the constraint approach, we
develop a quaternion ANOVA model (QANOVA) and its functional extension for
making inference decisions about the eect of factor covariates on orientation data.
We illustrate our methodology using experimental data obtained from the HU-
MOSIM laboratory at the University of Michigan. Using this data we analyze and
develop a prediction model for the orientation trajectory of the right hand during un-
laden reach motions. Given the initial and nal orientation we use a speed adjusted
spherical linear interpolation, or slerp, to predict the orientation trajectory path be-
tween them. Our functional regression model shows that deviations from this slerp
trajectory cannot be suciently explained by anthropometry or target information.