Download presentation
Presentation is loading. Please wait.
Published byΚύμα Μαυρογένης Modified over 5 years ago
1
Quaternions are back!!! A global quaternion q is defined as q = q0 + q where q = q1I+ q2 J+ q3K . where q0 is a scalar and q is a vector. A quaternion can also be shown in its flag form: q = q0 + q1i+ q2 j + q3k . where i, j and k are the flags (unit vectors) defined as follows: i2 = j2 = k2 = ijk = -1; ij = -ji = k; jk = - kj = i; ki = -ik = j. Addition of two quaternions is a quaternion (closure under addition) q + p = (q0 + q1i+ q2 j + q3k) + (p0 + p1i+ p2 j + p3k) = (q0 + p0) + (q1 + p1) i + (q2 + p2) j + (q3 + p3) k Quaternion addition is commutative, q + p = p + q, and associative (q + p) + r = q + (p + r) (easy to prove).
2
Product of quaternions and other properties ...
The product of two quaternions is a quaternion defined as follows: qp = (q0 + q)(p0 + p) = q0p0 + q0p + p0q + qp, where: qp = q x p – q . p Here qp is the cross product minus the dot product of vectors q and p (in that order, q goes first). In the product of two quaternions the scalar part is “q0p0 – q . p“, and the rest is a vector part. qp = q0p0 – q.p + q0p + p0q + q x p Quaternion multiplication is not commutative, however it is associative, and distributes over addition. That is, for three quaternions p, q and r: (pq)r = p(qr) and (p + q)r = pr + qr
3
Product of quaternions: Exercise # 28
Exercise: Given p = 3 + i – 2j + k and q = 2 – i +2j +3k, calculate their product. Answer: The product is given by pq = q0p0 – p.q + q0p + p0q + p x q = 8 - 9i - 2j + 11k First find the dot product: p.q = (1)*(-1) + (-2)*(2) + (1)*(3) = (-1) + (-4) + (3) = -2. Next the cross product: p x q = [ i j k] [ ] = (-6 – 2)i - (3 – (-1))j + (2 – 2)k = -8i -4j [ ] Etc … REMEMBER: WHATEVER YOU DO WITH A QUATERNION PRODUCT YOU MUST END UP WITH A SCALAR FOLLOWED BY A VECTOR (any of them can be a 0)!
4
Product of quaternions and other properties ...
A quaternion q = q0 + q has a conjugate q* = q0 – q (similar to complex numbers). If q = q0 + q1I + q2 J + q3K then q* = q0 - q1I - q2 J - q3K . Hence: q + q* = 2q0 and qq* = q*q = |q|2 = (q0)2 + (q1)2 + (q2)2 + (q3)2 (verify this!) A quaternion has an inverse q-1 = 1/q = q*/|q|2 A unit quaternion is such that |q| = 1 and for this unit quaternion q-1 = q*. The unit quaternion is: q = 1 + 0, that is, the unit quaternion has the scalar part of 1 (hence: (q0)2 + (q1)2 + (q2)2 + (q3)2 = 1) and the vector part of 0. The zero and the negative (additive inverse) quaternions are trivially defined as “0” and “-q”.
5
Evaluating a Unit quaternion:Exercise # 29
A unit quaternion is one such that |q| = 1 and for the unit quaternion q-1 = q* qq* = q*q = |q| = (q0)2 + (q1)2 + (q2)2 + (q3)2 = 1 Example: Given the quaternion q = q0 + q = i – 4.5 j k, calculate the corresponding unit quaternion p. Solution: |q| = (q0)2 + (q1)2 + (q2)2 + (q3)2 = sqrt( ) = sqrt(30.27) = p = q/|q| = i – j k. Thus, |p| = = = (it’s 1 with round off errors) Also p* = i j k. It’s easy to verify that pp* = p*p = 1.
6
Quaternions as 4 x 4 matrices
As we know, the product of two quaternions can be expressed using algebra of matrices. For this let: p = p0 + p = p0 + p1i+ p2 j+ p3k, and q = q0 + q = q0 + q1i+ q2 j+ q3k, and let’s designate the product as the quaternion r such that: r = pq = r0 + r = r0 + r1i+ r2 j+ r3k We can verify that the product pq can be written in matrix notation as follows: p0 -p1 -p2 -p3 p1 p0 -p3 p2 p2 p3 p0 -p1 p3 -p2 p1 p0 r0 r1 r2 r3 q0 q1 q2 q3 r = = = Pq It’s easy to verify that matrix quaternion Q has the property of a rotation matrix, that is: Q-1 = Qt. Also, matrix Q can be represented as follows: Q = , where p’ = , compare p’ with vector v used in the Rodrigues formula (Ch 3a, # 2). 0 -p3 p2 p p1 -p2 p1 0 p pt p p0 I3 + p’
7
Product of quaternions: Exercise # 30
Example: Given p = 3 + i – 2j + k and q = 2 – i +2j +3k, calculate their product using the quaternion matrix representation. Answer: Let r = pq, then: p0 -p1 -p2 -p3 p1 p0 -p3 p2 p2 p3 p0 -p1 p3 -p2 p1 p0 = r0 r1 r2 r3 q0 q1 q2 q3 2 -1 3 = Pq = 8 -9 -2 11 Therefore, r = pq = 8 – 9 i – 2 j + 11 k. As given, P must have an inverse and a transpose. Verify if Pt = P-1 (and be surprised!), otherwise calculate the formula for P-1 using the formula given in the previous slide. Also, find det(P) = 225 ≠ 1? Etc ..
8
Quaternion and vectors
A vector can be treated as a quaternion whose “scalar” (or “real” part) is 0: thus v R3 is now q R4 . This quaternion q with real part 0, is called a pure quaternion”. (The set Q0 of pure quaternions is a subset of the set Q of all quaternions). Multiplication of a quaternion and a vector is not a vector: qv = (q0 + q)(0 + v) = - q . v + q0v + q x v Q (not in Q0). Verify it! Two triple products generating a vector (pure quaternion): Whenever v is a vector (pure quaternion), and q is a quaternion, the products: qvq* and q*vq are pure quaternions (vectors). Most important results!!! Verify it! Typically we write Lq(v) = qvq* to indicate that qvq* is an operator (in fact a linear operator) Associating an angle to a unit quaternion: Let q = q0 + q be a unit or “normalized” quaternion, that is (q0)2 + |q|2 = 1. For any angle q we can associate (q0)2 = cos2 q and |q|2 = sin2 q and q is unique when -p < q p. Let now be u the unit vector that represents the direction of q. We write u = q/|q| = q/sin q. Hence q = q0 + q = cos q + u sin q. And we can easily verify that (important result!): q* = q0 - q = cos q - u sin q = cos (-q) + u sin (-q).
9
The Operator Lq(v) = qvq* is linear
Linear operator “Lq(v) = qvq*” satisfies the following property: For any two vectors a and b in R3 and for any scalar (real number) k, Lq is a linear operator if it satisfies: Lq(ka + b) = kLq(a) + Lq(b) Proof: (we use the property of quaternions being associative & distributive - slide #2 in this set of notes) Lq(ka + b) = q(ka + b)q* = (kqa + qb)q* = kqaq* + qbq* = kLq(a) + Lq(b) Therefore, the operator Lq(v) = qvq* is a linear operator (a most important property)
10
Quaternions and vectors: Exercise # 31
Exercise: Given the vector v = (3, -1, 2.5) and the quaternion q = q0 + q = -7 – 2i + 5j + 3k. Find the products qv, vq, qvq* and q*vq, verifying that qv and vq are quaternions while qvq* and q*vq are pure quaternions (vectors). Make quaternion r = vq a unit quaternion and find the angle q associated with r. Solution: qv = Etc...
11
Quaternion with Angle q = p/6 and vector k: Exercise # 32
Example: In this case q = p/6 and the unit quaternion is: q = cos q + k sin q = 3/2 + (1/2)k Assume that the basis vector is: v = 1i + 0j + 0k and let’s compute Lq(v) = w = qvq* = (3/2 + (1/2)k)(0+i) (3/2 - (1/2)k), that is: w = qvq* = (1/2)i + (3/2)j = cos(p/3)i + sin(p/3)j. We notice that the angle associate with w is 2*p/6 = p/3 and that w is a unit vector. Generalization: Assume that the angle is simply q with vector k. Then q = cos q + k sin q, while v = i and w = qvq*. Therefore: w = qvq* = (cos q + k sin q )(0 + i) (cos q - k sin q ) = cos2q I + sin2q k. Interpretations: 1. The quaternion operator qvq* has rotated the vector v counterclockwise (in the positive rotation sense), about k as an axis through an angle twice the quaternion’s angle while keeping the fixed the coordinate frame. This is called point or body rotation. OR: 2. The quaternion operator qvq* has rotated the coordinate frame (i, j, k) clockwise (in the negative rotation sense), about k as an axis through and angle - twice the quaternion’s angle while keeping fixed the vector v. This is called frame or global frame rotation. (In robotics the most common type of rotation is body rotation).
12
Quaternion and vectors: Exercise # 33
Example: Consider two unit quaternions p and q with both having the same unit vector u. Associated with p there is an angle a and associated with q there is an angle b. Prove that their product r = pq = cos g + u sin g is such that the unit vector is kept in the product and its angle is the sum of a and b, that is g = a + b. Proof: (See Notes 0b slide #3 for the trigonometry part ) We can write p = cos a + u sin a and q = cos b + u sin b. Then, we use the quaternion product rule to expand r = pq which yields r = pq = cos(a + b) + u sin(a + b) = cos g + u sin g. We proceed as follows: r = pq = (cos a + u sin a)(cos b + u sin b) = … Etc…
13
The Quaternion Rotation Operator General Formula
There are known “forms” to express the rotation operator w = qvq* where v is the input vector and q is a quaternion with magnitude |q| = 1. We have: w = qvq* = (q0 + q)(0 + v)(q0 – q) = (2(q0)2 - |q|2)v + 2(q . v)q + 2q0(q x v) = (2(q0)2 - 1)v + 2(q . v)q + 2q0(q x v). which is equivalent to Rodrigues formula for rotations (verify it!). Similarly, for the other quaternion operator : w = q*vq = (q0 - q)(0 + v)(q0 + q) = (2(q0)2 - |q|2)v + 2(v . q)q + 2q0(v x q) = (2(q0)2 - 1)v + 2(v . q)q + 2q0(v x q). where each term in these expressions can be written in matrix form. The matrix expansions are: w = qvq* = Q v (the matrix Q is given in the next slide) and w = q*vq = Qt v
14
The unit quaternion rotations properties
ROTATIONS DEFINED USING QUATERNIONS “For any unit quaternion q = q0 + q = cos q + u sin q and for any vector v R3, the action operator Lq(v) = qvq* on v may be interpreted geometrically as a rotation of the vector v though an angle 2q about q as the axis of rotation”. (Additional Equations: |m| = |n| = |n| where: |n| = |n x u| = |n||u| sin(p/2) = |n| m = Lq(n) = ((q0)2 - |q|2)n + 2(q . n)q + 2q0 (q x n), that is: Lq(n) = ((q0)2 - |q|2)n + 2q0|q|n = (cos2 q - sin2 q)n + (2cos q sin q)n = (cos 2q )n + (sin 2q)n
15
The Quaternion Rotation Operator Matrix Formula
We expand the terms in w = qvq* = Q v as follows: (2(q0)2 - 1) v = 2(q . v)q = 2q0(q x v) = v1 v2 v3 2(q0)2 – (q0)2 – (q0)2 – 1 v1 v2 v3 2(q1) q2q q3q1 2q1q (q2) q3q2 2q1q q2q (q3)2 v1 v2 v3 q0q q0q2 2q0q q0q1 -2q0q q0q therefore: w1 w2 w3 v1 v2 v3 2(q0)2 – 1 + 2(q1) q2q1 – 2q0q q3q1 + 2q0q2 2q1q q0q (q0)2 – 1 + 2(q2) q3q2 – 2q0q1 2q1q3 – 2q0q q2q q0q (q0)2 – 1 + 2(q3)2 = Q v = Lastly, w = q*vq = Qt v
16
The Quaternion Rotation Operator Matrix: Exercise # 34
Prove that any vector that lies on the axis of rotation is invariant, that is, if v = kq, then the rotation operator qvq* leaves the vector unchanged. Answer: We have (Verify it!): w = qvq = q(kq)q* = (2(q0)2 - 1)v + 2(q . v)q + 2q0(q x v) = (2(q0)2 - 1)(kq) + 2(q . kq)q + 2q0(q x kq) = k(q0)2 q – k|q|2q + 2k|q|2q = k((q0)2 + |q|2)q = k (1)q = kq = v
17
Rotation Examples: Exercise # 35
Exercise: Consider a rotation in R3 about an axis defined by the vector v = [1 1 1]t and the angle of rotation about the specified axis is f = 2p/3 = 120 degrees. Then, under this rotation, the vectors say ai becomes aj, bj becomes bk and ck becomes ci. Explain how this happens using quaternions. Answer: First we define the unit vector u in the direction of vector (1, 1, 1) as follows: u = [1/3 1/ 3 1/ 3] = i 1/3 + j 1/3 + k 1/3 Next, the appropriate angle q in the unit quaternion q is (1/2) of the angle of rotation, that is q = p/3 and thus q = cos q + u sin q = (1/2) + (i 1/3 + j 1/3 + k 1/3)(3/2) q0 = 1/2 and q = (1/2)i + (1/2)j + (1/2)k. If we check the effect of the operator qvq* on, say, the vector v = i, it is easy to evaluate the terms q . i = 1/2 and q x i = (1/2)j – (1/2)k and lastly w = qiq* = j. It is a simple exercise to verify that the frame rotation operator w = q*iq = k.
18
Exercise #36: Exercise: Prove that RZ,a can be derived from the quaternions formula Hint: See slide #13 - use the Rodrigues formula qvq* = (2(q0)2 - 1)v + 2(q . v)q + 2q0(q x v). Proof: (Use trig formulas: cos(2q) = 2cos2 q - 1, 2 sin q cos q = sin 2q, sin2 q + cos2 q =1) In this case u = [0 0 1]t and q = q0 + q = cos a/2 + u sin a/2, therefore q0 = cos a/2, q1 = q2 = 0, q3 = sin a/2, therefore: RZ,a = Q = as expected!!! 2(q0)2 – 1 + 2(q1) q2q1 – 2q0q q3q1 + 2q0q2 2q1q q0q (q0)2 – 1 + 2(q2) q3q2 – 2q0q1 2q1q3 – 2q0q q2q q0q (q0)2 – 1 + 2(q3)2 2(q0)2 – q0q 2q0q (q0)2 – ( (q0)2 + (q3)2 ) - 1 cos a = 2cos2 (a/2) – 1 sin a = 2sin(a/2)cos(a/2) 1 = 2(cos2 (a/2) + (cos2 (a/2) ) - 1 , and since: cos a -sin a sin a cos a 0
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.