Presentation is loading. Please wait.

Presentation is loading. Please wait.

More Rigid Transforms, 3D Rotations

Similar presentations


Presentation on theme: "More Rigid Transforms, 3D Rotations"โ€” Presentation transcript:

1 More Rigid Transforms, 3D Rotations
ECE 383/ ME 442 More Rigid Transforms, 3D Rotations 1

2 Agenda Working with transforms 3D rotations and representations

3 Operations on Transforms
Application Composition Inversion Interpolation Differentiation Accomplish: changes of coordinate frame Accomplish: movement

4 Composing 2D transformations
Using the representation q=( ๐‘ก ,๐œƒ) with ๐‘ก =( ๐‘ก ๐‘ฅ , ๐‘ก ๐‘ฆ ) ๐‘‡ ๐‘ž ๐‘ฅ =๐‘… ๐œƒ ๐‘ฅ + ๐‘ก Suppose this is followed by another transformation ๐‘‡ ๐‘ž โ€ฒ with ๐‘ž โ€ฒ = ๐‘ก โ€ฒ , ๐œƒ โ€ฒ . Thenโ€ฆ ๐‘‡ ๐‘ž โ€ฒ ๐‘‡ ๐‘ž ๐‘ฅ =๐‘… ๐œƒ โ€ฒ ๐‘… ๐œƒ ๐‘ฅ + ๐‘ก + ๐‘ก โ€ฒ =๐‘… ๐œƒ โ€ฒ ๐‘… ๐œƒ ๐‘ฅ +๐‘… ๐œƒ โ€ฒ ๐‘ก + ๐‘ก โ€ฒ Which is equivalent to the transform ๐‘‡ ๐‘žโ€ฒโ€ฒ represented by ๐‘ž โ€ฒโ€ฒ = ๐‘… ๐œƒ โ€ฒ ๐‘ก + ๐‘ก โ€ฒ ,๐œƒ+ ๐œƒ โ€ฒ

5 Rigid Transformation in 3D
q = (R,tx,ty,tz) with R a 3x3 rotation matrix Robot R0๏ƒŒR3 given in reference frame T0 Whatโ€™s the new robot Rq? {Tq(x,y,z) | (x,y,z) ๏ƒŽ R0} Define rigid transformation Tq(x,y,z) : R3๏‚ฎ R3 R x y z tx ty tz Tq(x,y,z) = + 3D rotation matrix Affine translation 5

6 3-D Rigid Rotations r11 r12 r13 r21 r22 r23 r31 r32 r33 det(A) = +1
Orthogonal rows and columns: ATA=I, AAT=I ||Ax|| = ||x|| for any x, L2 norm ||.|| Product of two rotations is a rotation (0,1,0) (r11,r21,r31) (Right-handed coordinate system) (r13,r23,r33) (1,0,0) (1,0,0) (r12,r22,r32) (0,0,1) (0,0,1) 6

7 Coordinate Frames R R-1 = RT Local frame World frame ๐‘Ÿ 13 ๐‘Ÿ 23 ๐‘Ÿ 33
๐‘Ÿ 13 ๐‘Ÿ 23 ๐‘Ÿ 33 (0,1,0) R ๐‘ฅ ๐‘ฆ ๐‘ง ๐‘Ÿ 11 ๐‘Ÿ 21 ๐‘Ÿ 31 (1,0,0) R ๐‘ฅ ๐‘ฆ ๐‘ง ๐‘Ÿ 12 ๐‘Ÿ 22 ๐‘Ÿ 32 (0,0,1) R-1 = RT

8 Composing 3D transformations
Using the representation q=(๐‘…, ๐‘ก ) with ๐‘ก =( ๐‘ก ๐‘ฅ , ๐‘ก ๐‘ฆ , ๐‘ก ๐‘ง ) ๐‘‡ ๐‘ž ๐‘ฅ =๐‘…โ‹… ๐‘ฅ + ๐‘ก Suppose this is followed by another transformation ๐‘‡ ๐‘ž โ€ฒ with ๐‘ž โ€ฒ =(๐‘…โ€ฒ, ๐‘ก โ€ฒ). Thenโ€ฆ ๐‘‡ ๐‘ž โ€ฒ ๐‘‡ ๐‘ž ๐‘ฅ = ๐‘… โ€ฒ โ‹… ๐‘…โ‹… ๐‘ฅ + ๐‘ก + ๐‘ก โ€ฒ = ๐‘… โ€ฒ โ‹…๐‘… ๐‘ฅ + ๐‘… โ€ฒ โ‹… ๐‘ก + ๐‘ก โ€ฒ Which is equivalent to the transform ๐‘‡ ๐‘žโ€ฒโ€ฒ where ๐‘ž โ€ฒโ€ฒ = ๐‘… โ€ฒ โ‹…๐‘…, ๐‘… โ€ฒ โ‹… ๐‘ก + ๐‘ก โ€ฒ

9 Interpolating 2D rotations
Say we want to blend smoothly from ๐‘… ๐œƒ to ๐‘… ๐œƒ โ€ฒ with a parameter ๐‘ขโˆˆ[0,1] (๐‘ข=0 gives ๐‘… ๐œƒ , ๐‘ข=1 gives ๐‘…(๐œƒโ€™)) Blending matrices doesnโ€™t work: (1โˆ’๐‘ข)๐‘…(๐œƒ)+๐‘ข ๐‘…(๐œƒโ€™) isnโ€™t in general a rotation matrix Blending angles ๐‘… 1โˆ’๐‘ข ๐œƒ+๐‘ข ๐œƒ โ€ฒ โ€ฆ sort of works. What about the boundary at 0 and 2๐œ‹? Naรฏve blend ๐œƒ Geodesic blend: pick minimum of CW and CCW displacement ๐œƒ ๐œƒโ€ฒ ๐œƒโ€ฒ

10 Topological spaces Three representations of 2D rotations:
Representation 1: Angle ๐œƒโˆˆ[0,2๐œ‹) Representation 2: Matrix ๐‘…= ๐‘Ÿ 11 ๐‘Ÿ 12 ๐‘Ÿ 21 ๐‘Ÿ with constraints ๐‘… ๐‘‡ ๐‘…=๐ผ (in other words, ๐‘Ÿ ๐‘Ÿ 12 2 = ๐‘Ÿ ๐‘Ÿ 22 2 =1 and ๐‘Ÿ 11 ๐‘Ÿ 21 + ๐‘Ÿ 12 ๐‘Ÿ 22 =0) det(R)=+1 Representation 3: unit vector ๐‘ฅ = ๐‘ฅ 1 , ๐‘ฅ 2 ๐‘‡ with ๐‘ฅ =1 And a way to convert between them: ๐‘… ๐œƒ = cos ๐œƒ โˆ’ sin ๐œƒ sin ๐œƒ cos ๐œƒ ๐œƒ ๐‘… =atan2( ๐‘Ÿ 21 , ๐‘Ÿ 11 ) (here atan2 gives a range of [0,2๐œ‹) ) ๐‘ฅ ๐œƒ = cos ๐œƒ , sin ๐œƒ ๐‘‡ , ๐‘ฅ ๐‘… = ๐‘Ÿ 11 , ๐‘Ÿ 21 ๐‘‡ , ๐‘… ๐‘ฅ = ๐‘ฅ 1 โˆ’ ๐‘ฅ 2 ๐‘ฅ 2 ๐‘ฅ 1 But rotations donโ€™t โ€œblendโ€ in the way they would on either 0,2๐œ‹ , ๐‘… 2 , or in ๐‘€ 2,2 โ€ฆ Fundamentally different topology

11 Some Important Topological Spaces
R: real number line Rn: N-dimensional Cartesian space S1: boundary of circle in 2D S2: surface of sphere in 3D SO(2), SO(3): set of 2D, 3D orientations (special orthogonal group) SE(2), SE(3): set of rigid 2D, 3D transformations (special Euclidean group) Cartesian product A x B, power notation An = A x A โ€ฆ x A Homeomorphism ~ denotes topological equivalence Continuous mapping with continuous inverse (bijective) Cube ~ S2 SO(2) ~ S1 SE(3) ~ SO(3) x R3

12 Topology of SO(3) r11 r12 r13 r21 r22 r23 r31 r32 r33
9 entries, constrained by: Orthogonal rows and columns: ATA=I, AAT=I det(A) = +1 (+/- 1 is implied by the first condition) Six (Row-wise) orthogonality constraints: 1 = ๐‘Ÿ ๐‘Ÿ ๐‘Ÿ 13 2 1 = ๐‘Ÿ ๐‘Ÿ ๐‘Ÿ 23 2 1 = ๐‘Ÿ ๐‘Ÿ ๐‘Ÿ 33 2 0 = ๐‘Ÿ 11 ๐‘Ÿ 21 + ๐‘Ÿ 12 ๐‘Ÿ 22 + ๐‘Ÿ 13 ๐‘Ÿ 23 0 = ๐‘Ÿ 11 ๐‘Ÿ 31 + ๐‘Ÿ 12 ๐‘Ÿ 32 + ๐‘Ÿ 13 ๐‘Ÿ 33 0 = ๐‘Ÿ 21 ๐‘Ÿ 31 + ๐‘Ÿ 22 ๐‘Ÿ 32 + ๐‘Ÿ 23 ๐‘Ÿ 33 9 variables - 6 non-redundant constraints => SO(3) has 3 degrees of freedom 12

13 4 representations of 3D rotations
3x3 rotation matrix R Euler angles REuler(f,q,y) Axis angle RAA(v,q) Quaternion RQuat(q) All representations are โ€œequivalentโ€ but may have certain mathematical or computational advantages

14 Axis-aligned rotations
Rotate about: Z axis Y axis X axis cos ฮธ -sin ฮธ 0 sin ฮธ cos ฮธ 0 cos ฮธ sin ฮธ -sin ฮธ cos ฮธ 0 cos ฮธ -sin ฮธ 0 sin ฮธ cos ฮธ 14

15 Parameterization of SO(3)
Euler angles: (f,q,y) x y z q x y z x y z f x y z 1 ๏ƒ  2 ๏ƒ  3 ๏ƒ  4 15

16 Euler Angles Which axes to pick, and what order? Convention A,B,C
REuler(f,q,y) = RA(f)RB(q)RC(y) E.g., ZYZ, ZYX (roll-pitch-yaw), etc 16

17 Euler Angles Which axes to pick, and what order? Disadvantages
Convention A,B,C REuler(f,q,y) = RA(f)RB(q)RC(y) E.g., ZYZ, ZYX (roll-pitch-yaw), etc Disadvantages Must constrain to range of values Singularities, e.g. ZYZ when q=0 or p (Gimbal lock) Interpolation? 17

18 Axis-Angle Representation
Every rotation matrix R can be obtained by rotating the identity matrix by some angle ฮธ about some axis v! R v = v

19 Axis-Angle Representation
Axis v (||v||=1), angle ฮธ Rodriguesโ€™ formula: rotate x about v -> xโ€™ xโ€™ = x cos ฮธ + (v x x) sin ฮธ + v (vT x) (1 - cos ฮธ) Or in matrix formโ€ฆ RAA(ฮธ,v) = cos ฮธ I + sin ฮธ [v] + (1 - cos ฮธ) v vT Cross product matrix 0 -vz vy vz vx -vy vx 0

20 Recovering Axis and Angle from the Rotation Matrix
ฮธ = Angle(R) = cos-1((r11+r22+r33-1)/2) = cos-1((tr(R)-1)/2) v = Axis(R) = 1/(2 sin ฮธ) r32-r23 r13-r31 r21-r12

21 Properties of Axis-Angle
Disadvantages: Non unique: RAA(ฮธ,v)=RAA(-ฮธ,-v) (can constrain ฮธ to range [0,p]) 4 parameters + one unit length constraint ||v||=1; dealing with this constraint is sometimes annoying, for example, in interpolation, optimization, or sampling Unique encoding: vector w = ฮธv ฮธ = ||w||, v = w/||w|| โ€œExponential mapโ€ REM(w) = RAA( ||w|| , w/||w|| )

22 Quaternion representation
Generalization of complex numbers Complex z=z0+i z1, with |z|=1 can represent a 2D rotation. Whatโ€™s the 3D analogue? q = q0+q1i + q2j +q3k, where i2 = j2 = k2 = -1 i = jk = -kj j = ki = -ik k = ij = -ji Quaternions were a forerunner of vectors and were once mandatory of all students of physics and math!

23 Unit quaternion representation
q = (q0,q1,q2,q3), ||q||=1 Related to axis angle: q = (cos q/2,vx sin q/2, vy sin q/2, vz sin q/2) 2(q02+q12)-1 2(q1q2-q0q3) 2(q1q3+q0q2) 2(q1q2+q0q3) 2(q02+q22)-1 2(q2q3-q0q1) 2(q1q3-q0q2) 2(q2q3+q0q1) 2(q02+q32)-1 RQ(q) =

24 Properties of Unit Quaternions
4-sphere: 3D manifold in 4D space Non-unique: Double cover of SO(3) Advantages (widely used in computer animation): Quaternion multiplication = rotation composition (slightly faster than matrix *) Curve interpolation formulas (Shoemake, โ€˜85)

25 Summary Rotation matrix Euler angles Axis-angle
9 parameters rij in range [-1,1] Constraint: determinant +1 Advantages: composition, inversion are easy Euler angles 3 parameters (f,q,y) in range [0,2p) Axes picked by convention (e.g., Roll-Pitch-Yaw) Advantages: no constraints, simple interpolation โ€œworksโ€ Disadvantages: multiple representation, singularities, composition & inversion not easy Axis-angle 4 parameters (q,v), q in [0,p] Constraint: |v|=1 Advantages: intuitive, inversion is easy Disadvantages: constraint, composition & interpolation not easy , multiple representation at p Moment representation (aka exponential map) 3 parameters w (= q*v), ||w||<=p Advantages: no constraints, inversion easy, relation to angular velocity (as we shall see soon) Disadvantages: composition & interpolation not easy, multiple representation at p Quaternion 4 parameters q=(q0,q1,q2,q3) Constraint: |q|=1 Advantages: composition & interpolation formulas, inversion easy Disadvantages: constraint, multiple representation R(q) = R(-q)

26 Notion of Distance ฮธ(R1TR2) = cos-1 ((tr(R1TR2)-1)/2) measures the minimum angle needed to rotate from frame R1 to R2 Makes a good distance metric

27 Actually a geodesic in SO(3)!
Rotation in Motion Interpolating between two rotation matrices A and B We want a path X(s) : [0,1] -> SO(3) with R(0) = A and R(1) = B Let v = Axis(ATB), ฮธ = Angle(ATB) Verify that X(s) = A RAA(sฮธ,v) satisfies the desired properties Actually a geodesic in SO(3)!

28 Differentiating 2D rotations
๐‘… ๐œƒ = cos ๐œƒ โˆ’ sin ๐œƒ sin ๐œƒ cos ๐œƒ ๐‘…โ€™ ๐œƒ = โˆ’ sin ๐œƒ โˆ’ cos ๐œƒ cos ๐œƒ โˆ’sin ๐œƒ Interpretation: Suppose the angle moves as a function of time ๐œƒ ๐‘ก , and we wish to observe the movement of a point ๐‘ฆ ๐‘ก =๐‘… ๐œƒ(๐‘ก) ๐‘ฅ where the original coordinates ๐‘ฅ are not time-varying By the chain rule, ๐‘ฆ โ€ฒ ๐‘ก = ๐œƒ โ€ฒ (๐‘ก) ๐‘‘ ๐‘‘๐œƒ ๐‘… ๐œƒ ๐‘ก โ‹… ๐‘ฅ (Convince yourself by writing out the components of ๐‘ฆ(๐‘ก)) So, the product ๐‘… โ€ฒ ๐œƒ โ‹… ๐‘ฅ gives the velocity the point ๐‘ฆ would rotate if moved at a constant velocity ๐‘… โ€ฒ ๐œƒ โ‹… ๐‘ฅ is perpendicular to ๐‘ฆ and of the same magnitude

29 Angular Velocities in 2D
For a rotation trajectory ๐‘… ๐œƒ ๐‘ก , we can show: ๐‘‘ ๐‘‘๐‘ก ๐‘… ๐œƒ ๐‘ก = ๐‘‘ ๐‘‘๐‘ก cos ๐œƒ ๐‘ก โˆ’ sin ๐œƒ ๐‘ก sin ๐œƒ ๐‘ก cos ๐œƒ ๐‘ก = โˆ’ sin ๐œƒ ๐‘ก ๐œƒโ€ฒ(๐‘ก) โˆ’ cos ๐œƒ ๐‘ก ๐œƒโ€ฒ(๐‘ก) cos ๐œƒ ๐‘ก ๐œƒโ€ฒ(๐‘ก) โˆ’ sin ๐œƒ ๐‘ก ๐œƒโ€ฒ(๐‘ก) = ๐œƒ โ€ฒ ๐‘ก 0 โˆ’ ๐‘… ๐œƒ ๐‘ก => ๐œƒ โ€ฒ ๐‘ก is the angular velocity For a point in world coordinates ๐‘ ๐‘ก =๐‘… ๐œƒ ๐‘ก ๐‘ 0 , we have ๐‘ โ€ฒ (๐‘ก)= ๐œƒ โ€ฒ ๐‘ก 0 โˆ’ ๐‘ ๐‘ก

30 Angular Velocities in 3D
For parameterized rotation trajectory REM(wt), we can show: d/dt REM(wt) = [w] REM(wt) => |w| is the speed of rotation [w] is the cross product matrix => w x x is the velocity of some point x, specified in world coordinates, attached to the frame as it rotates => w is the angular velocity

31 Recap 5 operations on transforms: Four common representations of SO(3)
Application to points / directions Composition Inversion Interpolation Differentiation Four common representations of SO(3) All four implemented robustly in Python klampt.so3 module, C++ in KrisLibrary/math3d Notion of distance, geodesic, velocity in SO(3)

32 Next Week Lab: Intro to Python and Klampโ€™t


Download ppt "More Rigid Transforms, 3D Rotations"

Similar presentations


Ads by Google