Linear Algebra Review Rigid Body Motion in 2D Rigid Body Motion in 3D Jana...

37
• Linear Algebra Review Rigid Body Motion in 2D Rigid Body Motion in 3D Jana Kosecka, CS 685

Transcript of Linear Algebra Review Rigid Body Motion in 2D Rigid Body Motion in 3D Jana...

Page 1: Linear Algebra Review Rigid Body Motion in 2D Rigid Body Motion in 3D Jana …kosecka/cs685/cs685-rbm.pdf · 2014-08-27 · CS223b, Jana Kosecka# Title: cs685-rbm.ppt Author: Jana

•  Linear Algebra Review Rigid Body Motion in 2D Rigid Body Motion in 3D Jana Kosecka, CS 685 #

Page 2: Linear Algebra Review Rigid Body Motion in 2D Rigid Body Motion in 3D Jana …kosecka/cs685/cs685-rbm.pdf · 2014-08-27 · CS223b, Jana Kosecka# Title: cs685-rbm.ppt Author: Jana

Why do we need Linear Algebra?#

•  We will associate coordinates to#–  3D points in the scene#–  2D points in the CCD array#–  2D points in the image#

•  Coordinates will be used to#–  Perform geometrical transformations#–  Associate 3D with 2D points#

•  Images are matrices of numbers#–  We will find properties of these numbers#

Page 3: Linear Algebra Review Rigid Body Motion in 2D Rigid Body Motion in 3D Jana …kosecka/cs685/cs685-rbm.pdf · 2014-08-27 · CS223b, Jana Kosecka# Title: cs685-rbm.ppt Author: Jana

Matrices#

mnmnmn BAC ××× +=Matrix Sum:#

ijijij bac +=

!"

#$%

&=!

"

#$%

&+!"

#$%

&

6478

5126

1352

Example:#

A and B must have the same dimensions#

Page 4: Linear Algebra Review Rigid Body Motion in 2D Rigid Body Motion in 3D Jana …kosecka/cs685/cs685-rbm.pdf · 2014-08-27 · CS223b, Jana Kosecka# Title: cs685-rbm.ppt Author: Jana

Matrices#

pmmnpn BAC ××× =

Product:#

∑=

=m

kkjikij bac

1

!"

#$%

&=!

"

#$%

&!"

#$%

&

11192917

5126

.1352

Examples:#

!"

#$%

&=!

"

#$%

&!"

#$%

&

10173218

1352

.5126

nnnnnnnn ABBA ×××× ≠

A and B must have compatible dimensions#

Page 5: Linear Algebra Review Rigid Body Motion in 2D Rigid Body Motion in 3D Jana …kosecka/cs685/cs685-rbm.pdf · 2014-08-27 · CS223b, Jana Kosecka# Title: cs685-rbm.ppt Author: Jana

Matrices#

mnT

nm AC ×× =Transpose:#

jiij ac = TTT ABAB =)(

TTT BABA +=+ )(

If # AAT = A is symmetric#

Examples:#

!"

#$%

&=!

"

#$%

&

5216

5126 T

!"

#$%

&=

!!!

"

#

$$$

%

&

852316

835126 T

Page 6: Linear Algebra Review Rigid Body Motion in 2D Rigid Body Motion in 3D Jana …kosecka/cs685/cs685-rbm.pdf · 2014-08-27 · CS223b, Jana Kosecka# Title: cs685-rbm.ppt Author: Jana

Matrices#

Determinant:#

131521352

det −=−="#

$%&

'Example:#

A must be square#

3231

222113

3331

232112

3332

232211

333231

232221

131211

detaaaa

aaaaa

aaaaa

aaaaaaaaaa

+−=

"""

#

$

%%%

&

'

122122112221

1211

2221

1211det aaaaaaaa

aaaa

−=="#

$%&

'

Page 7: Linear Algebra Review Rigid Body Motion in 2D Rigid Body Motion in 3D Jana …kosecka/cs685/cs685-rbm.pdf · 2014-08-27 · CS223b, Jana Kosecka# Title: cs685-rbm.ppt Author: Jana

Matrices#

IAAAA nnnnnnnn == ××−

×−

×11

Inverse:# A must be square#

!"

#$%

&

−=!

"

#$%

&−

1121

1222

12212211

1

2221

1211 1aaaa

aaaaaaaa

Example:# !"

#$%

&

−=!

"

#$%

&−

6125

281

5126 1

!"

#$%

&=!

"

#$%

&=!

"

#$%

&!"

#$%

&

−=!

"

#$%

&!"

#$%

&−

1001

280028

281

5126

.6125

281

5126

.5126 1

Page 8: Linear Algebra Review Rigid Body Motion in 2D Rigid Body Motion in 3D Jana …kosecka/cs685/cs685-rbm.pdf · 2014-08-27 · CS223b, Jana Kosecka# Title: cs685-rbm.ppt Author: Jana

2D,3D Vectors#

P#

x1#

x2#

θ#v#

Magnitude:# 22

21|||| xx +=v

Orientation:# !!"

#$$%

&= −

1

21tanxx

θ

!!"

#$$%

&=

||||,||||||||

21

vvvv xx

Is a unit vector#

If # 1|||| =v , # v is a UNIT vector#

Page 9: Linear Algebra Review Rigid Body Motion in 2D Rigid Body Motion in 3D Jana …kosecka/cs685/cs685-rbm.pdf · 2014-08-27 · CS223b, Jana Kosecka# Title: cs685-rbm.ppt Author: Jana

Vector Addition, Subtraction, Scalar Product#

v#u#

u+v#

u#v#

u-v#

v#av#

Page 10: Linear Algebra Review Rigid Body Motion in 2D Rigid Body Motion in 3D Jana …kosecka/cs685/cs685-rbm.pdf · 2014-08-27 · CS223b, Jana Kosecka# Title: cs685-rbm.ppt Author: Jana

Inner (dot) Product#

v#u#

α#The inner product is a SCALAR!#

norm of a vector#

Page 11: Linear Algebra Review Rigid Body Motion in 2D Rigid Body Motion in 3D Jana …kosecka/cs685/cs685-rbm.pdf · 2014-08-27 · CS223b, Jana Kosecka# Title: cs685-rbm.ppt Author: Jana

Vector (cross) Product#

wvu ×=

The cross product is a VECTOR!#

w#v#

α#u#

Orientation:#

|| u || = ||v × w ||=||v |||w || sinαMagnitude:#

Page 12: Linear Algebra Review Rigid Body Motion in 2D Rigid Body Motion in 3D Jana …kosecka/cs685/cs685-rbm.pdf · 2014-08-27 · CS223b, Jana Kosecka# Title: cs685-rbm.ppt Author: Jana

Standard base vectors:#

Coordinates of a point in space:#

Orthonormal Basis in 3D#

Page 13: Linear Algebra Review Rigid Body Motion in 2D Rigid Body Motion in 3D Jana …kosecka/cs685/cs685-rbm.pdf · 2014-08-27 · CS223b, Jana Kosecka# Title: cs685-rbm.ppt Author: Jana

Vector (Cross) Product Computation#

w#v#

α#u#

Skew symmetric matrix associated with vector#

Page 14: Linear Algebra Review Rigid Body Motion in 2D Rigid Body Motion in 3D Jana …kosecka/cs685/cs685-rbm.pdf · 2014-08-27 · CS223b, Jana Kosecka# Title: cs685-rbm.ppt Author: Jana

2D Geometrical Transformations#

Page 15: Linear Algebra Review Rigid Body Motion in 2D Rigid Body Motion in 3D Jana …kosecka/cs685/cs685-rbm.pdf · 2014-08-27 · CS223b, Jana Kosecka# Title: cs685-rbm.ppt Author: Jana

2D Translation Equation#

x#

X !

Y !

tx#

ty#x’#

t#

Page 16: Linear Algebra Review Rigid Body Motion in 2D Rigid Body Motion in 3D Jana …kosecka/cs685/cs685-rbm.pdf · 2014-08-27 · CS223b, Jana Kosecka# Title: cs685-rbm.ppt Author: Jana

Homogeneous Coordinates#

Homogeneous coordinates:

Translation using matrices:

3

Page 17: Linear Algebra Review Rigid Body Motion in 2D Rigid Body Motion in 3D Jana …kosecka/cs685/cs685-rbm.pdf · 2014-08-27 · CS223b, Jana Kosecka# Title: cs685-rbm.ppt Author: Jana

Coordinate frames#•  In order to specify a position of a rigid body #In 2D space, we need to attach a coordinate #frame to it ##•  Frame defines a coordinate system#•  Coordinates of any point on the body can be #expressed in that coordinate system#

P = [x,y]’#

Page 18: Linear Algebra Review Rigid Body Motion in 2D Rigid Body Motion in 3D Jana …kosecka/cs685/cs685-rbm.pdf · 2014-08-27 · CS223b, Jana Kosecka# Title: cs685-rbm.ppt Author: Jana

Rotation Matrix#

!"

#$%

&!"

#$%

& −=!

"

#$%

&

yx

yx

θθ

θθ

cossinsincos

''

P#x#

Y’#

θ#y#

Counter-clockwise rotation of a coordinate#frame by an angle θ#

Counter-clockwise rotation of a coordinate frame#attached to a rigid body by an angle θ###

{A}#

{B}#

x’#

Page 19: Linear Algebra Review Rigid Body Motion in 2D Rigid Body Motion in 3D Jana …kosecka/cs685/cs685-rbm.pdf · 2014-08-27 · CS223b, Jana Kosecka# Title: cs685-rbm.ppt Author: Jana

Rotation Matrix#

Interpretations of the rotation matrix RAB##

{A}#

{B}#

Columns of RAB are the unit vectors of the axes of frame B expressed in coordinate frame A. Such rotation matrix transforms coordinates of points in frame B to points in frame A##

XA = RABXB

�RAB =

�cos � � sin �sin � cos �

Use of the rotation matrix as transformation RAB ##

Page 20: Linear Algebra Review Rigid Body Motion in 2D Rigid Body Motion in 3D Jana …kosecka/cs685/cs685-rbm.pdf · 2014-08-27 · CS223b, Jana Kosecka# Title: cs685-rbm.ppt Author: Jana

Rigid Body Transform#

{A}#

{B}#XA

XB

tAB

XA = XB + tAB

The points from frame A to frame B are transformed by the inverse of#(see example next slide) ##

XA = RABXB + tAB

T = (RAB , tAB)

tAB

T = (RAB , tAB)

Translation only, is the origin of the frame B expressed in the #Frame A #

Composite transformation: #

Transformation: #

XA =�

RAB tAB

0 1

⇥XB

Homogeneous coordinates #

Page 21: Linear Algebra Review Rigid Body Motion in 2D Rigid Body Motion in 3D Jana …kosecka/cs685/cs685-rbm.pdf · 2014-08-27 · CS223b, Jana Kosecka# Title: cs685-rbm.ppt Author: Jana

Example#

XA =

⇤cos � � sin � txsin � cos � ty

0 0 1

⌅XB

XA =

⇤0 �1 01 0 30 0 1

⌅XB � = 90o, tAB = [0, 3]Tfor#

{A}#

{B}#XA

XB

tAB

XA =

⇤231

⌅ XB =

⇤0�21

In homogeneous coordinates: #

Verify that the inverse of the above transform #Transforms coordinates in frame {A} to frame {B} #

Page 22: Linear Algebra Review Rigid Body Motion in 2D Rigid Body Motion in 3D Jana …kosecka/cs685/cs685-rbm.pdf · 2014-08-27 · CS223b, Jana Kosecka# Title: cs685-rbm.ppt Author: Jana

Degrees of Freedom#

R is 2x2 # 4 elements#

BUT! There is only 1 degree of freedom: θ#

The 4 elements must satisfy the following constraints:#

!"

#$%

&!"

#$%

& −=!

"

#$%

&

yx

yx

θθ

θθ

cossinsincos

''

Rows and columns are orthogonal and of unit length#Matrix is orientation preserving#

Next transformations in 3D.#

Page 23: Linear Algebra Review Rigid Body Motion in 2D Rigid Body Motion in 3D Jana …kosecka/cs685/cs685-rbm.pdf · 2014-08-27 · CS223b, Jana Kosecka# Title: cs685-rbm.ppt Author: Jana

3-D Euclidean Space - Vectors #

A “free” vector is defined by a pair of points :

Coordinates of the vector :

Page 24: Linear Algebra Review Rigid Body Motion in 2D Rigid Body Motion in 3D Jana …kosecka/cs685/cs685-rbm.pdf · 2014-08-27 · CS223b, Jana Kosecka# Title: cs685-rbm.ppt Author: Jana

3D Rotation of Points – Euler angles#Rotation around the coordinate axes, counter-clockwise:#

P#x#

Y’#P’# γ#

X’#

y#

z#

Page 25: Linear Algebra Review Rigid Body Motion in 2D Rigid Body Motion in 3D Jana …kosecka/cs685/cs685-rbm.pdf · 2014-08-27 · CS223b, Jana Kosecka# Title: cs685-rbm.ppt Author: Jana

Rotation Matrix#•  Euler theorem – any rotation can be expressed as a sequence of

rotations around different coordinate axes #•  Different order of rotations yields different final rotation#•  Rotation multiplication is not commutative#

•  Different ways how to obtain final rotation – rotation around 3 axes no successive rotations around same axes#

•  XYX, XZX, YXY, YZX, ZXZ, ZYZ – Eulerian involves repetition#•  Cardanian – no repetitions XYZ, XZY, YZX, YXZ, ZXY, ZYX. #•  Another widely used convention roll-pitch-yaw#

#

R = Rx (θr )Ry (θ p )Rz (θy )

Page 26: Linear Algebra Review Rigid Body Motion in 2D Rigid Body Motion in 3D Jana …kosecka/cs685/cs685-rbm.pdf · 2014-08-27 · CS223b, Jana Kosecka# Title: cs685-rbm.ppt Author: Jana

Rotation Matrices in 3D#

•  3 by 3 matrices#•  9 parameters – only three degrees of freedom#•  Representations – either three Euler angles#•  or axis and angle representation #

•  Properties of rotation matrices (constraints between the # elements)#

Page 27: Linear Algebra Review Rigid Body Motion in 2D Rigid Body Motion in 3D Jana …kosecka/cs685/cs685-rbm.pdf · 2014-08-27 · CS223b, Jana Kosecka# Title: cs685-rbm.ppt Author: Jana

Rotation Matrices in 3D#•  3 by 3 matrices#•  9 parameters – only three degrees of freedom#•  Representations – either three Euler angles#•  or axis and angle representation #

#•  Properties of rotation matrices (constraints between the # elements)#

Columns are orthonormal#

Page 28: Linear Algebra Review Rigid Body Motion in 2D Rigid Body Motion in 3D Jana …kosecka/cs685/cs685-rbm.pdf · 2014-08-27 · CS223b, Jana Kosecka# Title: cs685-rbm.ppt Author: Jana

Rotation Matrix#

•  Problem with 3 angle representations: singularities#

•  The mapping between angles and Rotation matrix is unique#

•  The inverse mapping between Rotation matrix and the angles sometimes cannot be computed or is not unique#

Angle Axis Representation: ##•  Two coordinates frames of arbitrary orientations can be related

by a single rotation about ‘some’ axis in space and an angle#

Page 29: Linear Algebra Review Rigid Body Motion in 2D Rigid Body Motion in 3D Jana …kosecka/cs685/cs685-rbm.pdf · 2014-08-27 · CS223b, Jana Kosecka# Title: cs685-rbm.ppt Author: Jana

Canonical Coordinates for Rotation#

By algebra#

By solution to ODE#

Property of R#

Taking derivative#

Skew symmetric matrix property#

Page 30: Linear Algebra Review Rigid Body Motion in 2D Rigid Body Motion in 3D Jana …kosecka/cs685/cs685-rbm.pdf · 2014-08-27 · CS223b, Jana Kosecka# Title: cs685-rbm.ppt Author: Jana

3D Rotation (axis & angle)#

with#

or#

Solution to the ODE#

Page 31: Linear Algebra Review Rigid Body Motion in 2D Rigid Body Motion in 3D Jana …kosecka/cs685/cs685-rbm.pdf · 2014-08-27 · CS223b, Jana Kosecka# Title: cs685-rbm.ppt Author: Jana

Rotation Matrices#

Given#

How to compute angle and axis#

Page 32: Linear Algebra Review Rigid Body Motion in 2D Rigid Body Motion in 3D Jana …kosecka/cs685/cs685-rbm.pdf · 2014-08-27 · CS223b, Jana Kosecka# Title: cs685-rbm.ppt Author: Jana

3D Translation of Points#

Translate by a vector #

P#x#Y’#

P’#

x’#

y#z#

z’#

t#

Page 33: Linear Algebra Review Rigid Body Motion in 2D Rigid Body Motion in 3D Jana …kosecka/cs685/cs685-rbm.pdf · 2014-08-27 · CS223b, Jana Kosecka# Title: cs685-rbm.ppt Author: Jana

Rigid Body Motion – Homogeneous Coordinates#

3-D coordinates are related by:

Homogeneous coordinates:

Homogeneous coordinates are related by:

Page 34: Linear Algebra Review Rigid Body Motion in 2D Rigid Body Motion in 3D Jana …kosecka/cs685/cs685-rbm.pdf · 2014-08-27 · CS223b, Jana Kosecka# Title: cs685-rbm.ppt Author: Jana

Rigid Body Motion – Homogeneous Coordinates#

3-D coordinates are related by:

Homogeneous coordinates:

Homogeneous coordinates are related by:

Page 35: Linear Algebra Review Rigid Body Motion in 2D Rigid Body Motion in 3D Jana …kosecka/cs685/cs685-rbm.pdf · 2014-08-27 · CS223b, Jana Kosecka# Title: cs685-rbm.ppt Author: Jana

Properties of Rigid Body Motions#

Rigid body motion composition#

Rigid body motion inverse#

Rigid body motion acting on vectors#

Vectors are only affected by rotation – 4th homogeneous coordinate is zero#

Page 36: Linear Algebra Review Rigid Body Motion in 2D Rigid Body Motion in 3D Jana …kosecka/cs685/cs685-rbm.pdf · 2014-08-27 · CS223b, Jana Kosecka# Title: cs685-rbm.ppt Author: Jana

Rigid Body Transformation#

Coordinates are related by:#Camera pose is specified by:#

Page 37: Linear Algebra Review Rigid Body Motion in 2D Rigid Body Motion in 3D Jana …kosecka/cs685/cs685-rbm.pdf · 2014-08-27 · CS223b, Jana Kosecka# Title: cs685-rbm.ppt Author: Jana

Rigid Body Motion#

•  Shown how to describe positions and orientations of coordinate frames (poses) with respect to the origin world frame#

•  Relative pose (R,T) – relationship between two consecutive poses#

CS223b, Jana Kosecka#