Orientatjon Orientatjon We will defjne orientatjon to mean an - - PowerPoint PPT Presentation
Orientatjon Orientatjon We will defjne orientatjon to mean an - - PowerPoint PPT Presentation
Orientatjon Orientatjon We will defjne orientatjon to mean an objects instantaneous rotatjonal confjguratjon This is the rotatjonal equivalent of positjon Rotatjonal State Representjng Positjons Cartesian
Orientatjon
- We will defjne ‘orientatjon’ to mean an
- bject’s instantaneous rotatjonal
confjguratjon
- This is the rotatjonal equivalent of positjon
- “Rotatjonal State”
Representjng Positjons
- Cartesian coordinates (x,y,z) are an easy and
natural means of representjng a positjon in 3D space
- There are many other alternatjves such as
Polar notatjon (r,θ,φ)
- Others can be defjned…
Representjng Orientatjons
- Is there a simple means of representjng a 3D
- rientatjon? (analogous to Cartesian coordinates?)
- Not really.
- There are several popular optjons though:
– Euler angles – Rotatjon vectors (axis/angle) – 3x3 matrices – Quaternions – and more…
Euler’s Theorem
- Euler’s Theorem: Any two independent orthonormal
coordinate frames can be related by a sequence of rotatjons (not more than three) about coordinate axes, where no two successive rotatjons may be about the same axis.
- Not to be confused with Euler angles, Euler integratjon, Newton-
Euler dynamics, inviscid Euler equatjons, Euler characteristjc…
- Leonard Euler (1707-1783)
Euler Angles
- This means that we can represent an orientatjon with 3
numbers.
- A sequence of rotatjons around principle axes is called an
Euler Angle Sequence.
- Assuming we limit ourselves to 3 rotatjons without successive
rotatjons about the same axis, we could use any of the following 12 sequences: XYZ XZY XYX XZX YXZ YZX YXY YZY ZXY ZYX ZXZ ZYZ
Euler Angles
- This gives us 12 redundant ways to store an
- rientatjon using Euler angles
- Difgerent industries use difgerent conventjons
for handling Euler angles (or no conventjons)
Euler Angles to Matrix Conversion
- To build a matrix from a set of Euler angles, we just
multjply a sequence of rotatjon matrices together:
=[ c yc z c y sz −s y sxs y cz−cxs z sxs y sz+c xcz sxc y c xs yc z+sx sz cx s ysz−s xcz c xc y]
R x⋅R y⋅R z=[ 1 c x sx −s x cx] ⋅[ c y −s y 1 s y c y ] ⋅[ c z s z −s z c z 1]
Euler Angle Order
- As matrix multjplicatjon is not commutatjve, the
- rder of operatjons is important
- Rotatjons are assumed to be relatjve to fjxed world
axes, rather than local to the object
- One can think of them as being local to the object if
the sequence order is reversed
Using Euler Angles
- To use Euler angles, one must choose one of
the 12 representatjons.
- There may be some practjcal difgerences
between them and the best sequence may depend on what exactly you are trying to accomplish.
- Euler angles can be stored in degrees, radians
- r …
Vehicle Orientatjon
- Generally, for vehicles, it is most convenient to
rotate in roll (z), pitch (x), and then yaw (y)
- In situatjons where there
is a defjnite ground plane, Euler angles can actually be an intuitjve representatjon
x y z
front of vehicle
Orientatjon HPR
Gimbal lock
- Gimbal = device used for
holding a gyroscope
- Illustrates problem with
interpolatjng Euler angles
- Gimbal lock is a basic
problem with representjng 3D rotatjons using Euler angles
Gimbal Lock
- One potentjal problem that Euler Angles can
sufger is the ‘gimbal lock’.
- This results when two axes efgectjvely line up,
resultjng in a temporary loss of a degree of freedom.
- This is related to the singularitjes in longitude
that you get at the north and south poles.
Gimbal Lock
- Roll, pitch, yaw
- Gimbal lock: reduced DOF
due to overlapping axes
Ref: htup://www.fio-emden.de/~hofgmann/gimbal09082002.pdf
Interpolatjng Euler Angles
- One can simply interpolate between the three values
independently
- This will result in the interpolatjon following a
difgerent path depending on which of the 12 schemes you choose
- This may or may not be a problem, depending on
your situatjon
- Interpolatjng near the ‘poles’ can be problematjc
- Note: when interpolatjng angles, remember to check
for crossing the +180/-180 degree boundaries
Euler Angles
- Euler angles are used in a lot of applicatjons, but they
tend to require some rather arbitrary decisions.
- They also do not interpolate in a consistent way (but
this isn’t always bad).
- They can sufger from Gimbal lock and related
problems.
- There is no simple way to concatenate rotatjons.
- Conversion to/from a matrix requires several
trigonometry operatjons.
- They are compact (requiring only 3 numbers).
Axis/Angle
- Euler’s Theorem also shows that any two
- rientatjons can be related by a single rotatjon about
some axis (not necessarily a principle axis)
- This means that we can represent an arbitrary
- rientatjon as a rotatjon about some unit axis by
some angle (4 numbers) (Axis/Angle form)
R = [ θ, ax, ay, az ]
Axis/Angle
a(x,y,z) θ
Axis/Angle to Matrix
- To generate a matrix as a rotatjon θ around an
arbitrary unit axis a:
[
ax
2+cθ(1−ax 2)
axa y(1−cθ)+az sθ axaz(1−cθ)−a y sθ axa y(1−cθ)−az sθ a y
2 +cθ(1−a y 2 )
a y az(1−cθ)+ax sθ axaz(1−cθ)+a ysθ a yaz(1−cθ)−a xsθ az
2+cθ(1−az 2) ]
Axis/Angle Representatjon
- Storing an orientatjon as an axis and an angle uses 4 numbers,
but Euler’s theorem says that we only need 3 numbers to represent an orientatjon
- Mathematjcally, this means that we are using 4 degrees of
freedom to represent a 3 degrees of freedom value
- This implies that there is possibly extra or redundant
informatjon in the axis/angle format
- The redundancy manifests itself in the magnitude of the axis
- vector. The magnitude carries no informatjon, and so it is
- redundant. To remove the redundancy, we choose to
normalize the axis, thus constraining the extra degree of freedom.
- Alternately, we can scale the axis by the angle and compact it
down to a single 3D vector (Rotatjon vector).
Rotatjon Vectors
- To convert a scaled rotatjon vector to a
matrix, one would have to extract the magnitude out of it and then rotate around the normalized axis
- Normally, rotatjon vector format is more
useful for representjng angular velocitjes and angular acceleratjons, rather than angular positjon (orientatjon)
Matrix Representatjon
- We can use a 3x3 matrix to represent an orientatjon
as well
- This means we now have 9 numbers instead of 3,
and therefore, we have 6 extra degrees of freedom
- NOTE: We don’t use 4x4 matrices here, as those are mainly useful
because they give us the ability to combine translatjons.
Matrix Representatjon
- 3 x 3 = 9 DOFs
- Those extra 6 DOFs manifest themselves as 3 scales
(x, y, and z) and 3 shears (xy, xz, and yz)
- If we assume the matrix represents a rigid transform
(orthonormal), then we can constrain the extra 6 DOFs
|a|=|b|=|c|=1 a=b×c b=c×a c=a×b
Matrix Representatjon
- Matrices are usually the most computatjonally
effjcient way to apply rotatjons to geometric data.
- Most orientatjon representatjons ultjmately need to
be converted into a matrix in order to do anything useful (transform verts…)
- Why then, shouldn’t we just always use matrices?
– Numerical issues – Storage issues – User interactjon issues – Interpolatjon issues
Rotatjons
- Euler angles
- Matrix
- Axis / angle
- Rotatjon Vector
Quaternions
Applicatjons of Quaternions
- Used to represent rotatjons and orientatjons of
- bjects in three-dimensional space in:
– Computer graphics – Control theory – Signal processing – Attjtude controls – Physics – Orbital mechanics – Quantum Computjng, quantum circuit design
29
From: http://en.wikipedia.org/wiki/Quaternion
Quaternions
- Quaternions are an interestjng mathematjcal
concept with a deep relatjonship with the foundatjons of algebra and number theory
- Invented by W.R.Hamilton in 1843
- In practjce, they are most useful as a means of
representjng orientatjons
- A quaternion has 4 components
q=[q0 q1 q2 q3 ]
Quaternions
Quaternions (Scalar/Vector)
- Sometjmes, they are writuen as the combinatjon of a
scalar value s and a vector value v where s=q0 v= [q1 q2 q3 ]
q= ⟨s,v ⟩
Quaternions (Imaginary Space)
- Quaternions are an extension to complex numbers
- Of the 4 components, one is a ‘real’ scalar number, and the
- ther 3 form a vector in imaginary ijk space!
q=q 0+iq 1+jq2+kq 3
i2=j2=k 2=ijk=−1 i=jk=−kj j=ki=−ik k=ij=− ji
Unit Quaternions
- For convenience, we will use only unit length quaternions, as
they will be suffjcient for our purposes and make things a litule easier
- These correspond to the set of vectors that form the ‘surface’
- f a 4D hypersphere of radius 1
- The ‘surface’ is actually a 3D volume in 4D space, but it can
sometjmes be visualized as an extension to the concept of a 2D surface on a 3D sphere
|q|=√q 0
2 +q1 2 +q 2 2 +q 3 2=1
Quaternions as Rotatjons
- A quaternion can represent a rotatjon by an angle θ
around a unit axis a:
- If a is unit length, then q will also be unit lenght
q=[cosθ 2 axsin θ 2 aysin θ 2 azsinθ 2 ]
- r
q=⟨cosθ 2 ,asinθ 2 ⟩
Quaternion length
|q|=√q0
2+q1 2+q2 2+q3 2
√cos2θ
2 +ax
2sin 2θ
2 +ay
2 sin2θ
2 +az
2sin 2θ
2
√cos2θ
2 +sin2θ 2 (ax
2 +ay 2 +az 2)
√cos2θ
2 +sin2θ 2 |a|
2=√cos2θ
2 +sin 2θ 2
√1=1
Polar Representatjon
- Remember a 2D unit complex number
cos + i sin = e
- A unit quaternion Q may be writuen as:
Q = (sin uq , cos) = cos + sin uq where uq is a unit 3-tuple vector
- We can also write this unit quaternion as:
Q = e
i uq
Quaternion to Matrix
- To convert a quaternion to a rotatjon matrix:
[
1−2q2
2−2q3 2
2q 1 q 2+2q 0 q 3 2q 1 q 3−2q 0 q 2 2q 1 q 2−2q 0 q 3 1−2q1
2−2q3 2
2q 2 q 3+2q 0 q 1 2q 1 q 3+2q 0 q 2 2q 2 q 3−2q 0 q 1 1−2q1
2−2q2 2 ]
Matrix to Quaternion
- Matrix to quaternion is also possible
- It involves a few ‘if’ statements, a square root,
three divisions, and some other stufg
Spheres
Think of a person standing on the surface of a big sphere (like a planet)
- From the person’s point of view,
- ne can move in along two
- rthogonal axes:
(front/back) and (lefu/right)
- There is no perceptjon of any
fjxed poles or longitude/latjtude, because no matuer which directjon he faces, he always has two
- rthogonal ways to go.
- From his point of view, one might as well be moving on a infjnite
2D plane, however if anyone goes too far in one directjon, he will come back to where he started!
Hyperspheres
- Now extend this concept to moving in the hypersphere
- f unit quaternions.
- The person now has three orthogonal directjons to go.
- No matuer how he is oriented in this space, he can
always go along some combinatjon of forward/backward, lefu/right and up/down
- If he goes too far in any one directjon, he will come
back to where he started.
Hyperspheres
- Now consider that a person’s locatjon on this
hypersphere represents an orientatjon.
- Any incremental movement along one of the
- rthogonal axes in curved space corresponds to an
incremental rotatjon along an axis in real space (distances along the hypersphere correspond to angles in 3D space).
- Moving in some arbitrary directjon corresponds to
rotatjng around some arbitrary axis.
- If you move too far in one directjon, you come back
to where you started (corresponding to rotatjng 360 degrees around any one axis).
Hyperspheres
- Also consider what happens if you rotate a
book 180 around x, then 180 around y, and then 180 around z
- You end up back where you started
- This corresponds to traveling along a triangle
- n the hypersphere where each edge is a 90
degree arc, orthogonal to each other edge
Representjng rotatjons
- A distance of x along the surface of the hypersphere
corresponds to a rotatjon of angle 2x radians.
- This means that moving along a 90 degree arc on the
hypersphere corresponds to rotatjng an object by 180 degrees
- Traveling 180 degrees corresponds to a 360 degree
rotatjon, thus gettjng you back to where you started.
- This implies that q and -q correspond to the same
- rientatjon
Combining rotatjons
Quaternion Dot Products
- The dot product of two quaternions works in the
same way as the dot product of two vectors:
- The angle between two quaternions in 4D space is
half the angle one would need to rotate from one
- rientatjon to the other in 3D space
p⋅q=p0 q0+p 1q1+p 2 q2+p 3q 3=|p||q|cos ϕ
Quaternion Multjplicatjon
- We can perform multjplicatjon on quaternions if we expand
them into their complex number form
- If q represents a rotatjon and q’ represents a rotatjon, then
qq’ represents q rotated by q’
- This follows very similar rules as matrix multjplicatjon (I.e.,
non-commutatjve)
q=q 0+iq 1+jq 2+kq 3 qq'=(q0+iq1+jq2+kq 3)(q0
' +iq1 ' +jq 2 ' +kq 3 ' )
⟨ss'−v⋅v' ,sv '+s' v+v×v⟩
Quaternion Multjplicatjon
- Two unit quaternions multjplied together will result
in another unit quaternion
- This corresponds to the same property of complex
numbers
- Remember that multjplicatjon by complex numbers
can be thought of as a rotatjon in the complex plane
- Quaternions extend the planar rotatjons of complex
numbers to 3D rotatjons in space
Quaternion Conjugate
– Given a quaternion:
- q = w + xi+ yj + zk
– The conjugate of quaternion q is q*, where:
- q* = w – xi – yj – zk
Quaternion Inverse
q
−1 = q∗¿
|q|2 ¿
– Can be used for division – Given a quaternion:
- q = w + xi+ yj + zk
– The inverse of quaternion q is q-1, where:
Linear Interpolatjon
- If we want to do a linear interpolatjon between two points a
and b in normal space Lerp(t,a,b) = (1-t)a + (t)b where t ranges from 0 to 1
- Note that the Lerp operatjon can be thought of as a weighted
average (convex)
- We could also write it in it’s additjve blend form:
Lerp(t,a,b) = a + t(b-a)
Spherical Linear Interpolatjon
- If we want to interpolate between two points
- n a sphere (or hypersphere), we don’t just
want to Lerp between them
- Instead, we will travel across the surface of
the sphere by following a ‘great arc’
Spherical Linear Interpolatjon
- We defjne the spherical linear interpolatjon of
two unit vectors in N dimensional space as:
Slerp (t,a,b)=sin ((1−t)θ ) sin θ a+ sin (tθ ) sin θ b where :θ= cos−1 (a⋅b)
A B C D
Quaternion Interpolatjon
- Remember that there are two redundant vectors in
quaternion space for every unique orientatjon in 3D space
- What is the difgerence between:
Slerp(t,a,b) and Slerp(t,-a,b) ?
- One of these will travel less than 90 degrees while the other
will travel more than 90 degrees across the sphere
- This corresponds to rotatjng the ‘short way’ or the ‘long way’
- Usually, we want to take the short way, so we negate one of
them if their dot product is < 0