Vectors, Matrices, Rotations - ccs.neu.edu fileBefore we go there – review of matrix transpose...

30
Vectors, Matrices, Rotations Robert Platt Northeastern University

Transcript of Vectors, Matrices, Rotations - ccs.neu.edu fileBefore we go there – review of matrix transpose...

Page 1: Vectors, Matrices, Rotations - ccs.neu.edu fileBefore we go there – review of matrix transpose Question: and matrix multiplication… Can represent dot product as a matrix multiply:

Vectors, Matrices, Rotations

Robert Platt Northeastern University

Page 2: Vectors, Matrices, Rotations - ccs.neu.edu fileBefore we go there – review of matrix transpose Question: and matrix multiplication… Can represent dot product as a matrix multiply:

You want to put your hand on the cup…

• Suppose your eyes tell you where the mug is and its orientation in the robot base frame (big assumption)

• In order to put your hand on the object, you want to align the coordinate frame of your hand w/ that of the object

• This kind of problem makes representation of pose important...

Why are we studying this?

Page 3: Vectors, Matrices, Rotations - ccs.neu.edu fileBefore we go there – review of matrix transpose Question: and matrix multiplication… Can represent dot product as a matrix multiply:

KIT Humanoid

Why are we studying this?

Joint encoders tell us head angleVisual perception tells us object position and orientation (pose)

Need to know where hand is...

Need to tell the hand where to move!

Page 4: Vectors, Matrices, Rotations - ccs.neu.edu fileBefore we go there – review of matrix transpose Question: and matrix multiplication… Can represent dot product as a matrix multiply:

Why are we studying this?

Page 5: Vectors, Matrices, Rotations - ccs.neu.edu fileBefore we go there – review of matrix transpose Question: and matrix multiplication… Can represent dot product as a matrix multiply:

Representing Position: Vectors

Page 6: Vectors, Matrices, Rotations - ccs.neu.edu fileBefore we go there – review of matrix transpose Question: and matrix multiplication… Can represent dot product as a matrix multiply:

Representing Position: vectors

x

y

p

5

2

(“column” vector)

(“row” vector)

x

y

z

p

Page 7: Vectors, Matrices, Rotations - ccs.neu.edu fileBefore we go there – review of matrix transpose Question: and matrix multiplication… Can represent dot product as a matrix multiply:

Representing Position: vectors

• Vectors are a way to transform between two different reference frames w/ the same orientation

• The prefix superscript denotes the reference frame in which the vector should be understood

Same point, two different reference frames

p

5

2

b

px

bx

by

py

Page 8: Vectors, Matrices, Rotations - ccs.neu.edu fileBefore we go there – review of matrix transpose Question: and matrix multiplication… Can represent dot product as a matrix multiply:

Representing Position: vectors

• Note that I am denoting the axes as orthogonal unit basis vectors

bx A vector of length one pointing in the direction of the base frame x axis

y axisby

py p frame y axis

This means “perpendicular”

p

5

2

b

px

bx

by

py

Page 9: Vectors, Matrices, Rotations - ccs.neu.edu fileBefore we go there – review of matrix transpose Question: and matrix multiplication… Can represent dot product as a matrix multiply:

What is a unit vector?

Vector length/magnitude:

Definition of unit vector:

These are the elements of a:

5

2

b x

How convert a non-zero vector a into a unit vector pointing in the same direction?

yb ˆ

Page 10: Vectors, Matrices, Rotations - ccs.neu.edu fileBefore we go there – review of matrix transpose Question: and matrix multiplication… Can represent dot product as a matrix multiply:

yyxx bababa

Orthogonal vectors

First, define the dot product:

a

b

Under what conditions is the dot product zero?

Page 11: Vectors, Matrices, Rotations - ccs.neu.edu fileBefore we go there – review of matrix transpose Question: and matrix multiplication… Can represent dot product as a matrix multiply:

A couple of other random things

bbb yxp ˆ2ˆ5

5

2

b xb ˆ

yb ˆ

x

y

zx

y

z

right-handed coordinate frame

left-handed coordinate frame

Vectors are elements of nR

Page 12: Vectors, Matrices, Rotations - ccs.neu.edu fileBefore we go there – review of matrix transpose Question: and matrix multiplication… Can represent dot product as a matrix multiply:

The importance of differencing two vectors

errb

effb

objectb xxx

The eff needs to make a Cartesian displacement of this much to reach the object

objectbxerr

bxeff

bx

Page 13: Vectors, Matrices, Rotations - ccs.neu.edu fileBefore we go there – review of matrix transpose Question: and matrix multiplication… Can represent dot product as a matrix multiply:

The importance of differencing two vectors

errb

effb

objectb xxx

bbx

by

effeffx

effy

objectobjectx

objecty

err

The eff needs to make a Cartesian displacement of this much to reach the object

Page 14: Vectors, Matrices, Rotations - ccs.neu.edu fileBefore we go there – review of matrix transpose Question: and matrix multiplication… Can represent dot product as a matrix multiply:

Representing Orientation: Rotation Matrices

• The reference frame of the hand and the object have different orientations

• We want to represent and difference orientations just like we did for positions…

Page 15: Vectors, Matrices, Rotations - ccs.neu.edu fileBefore we go there – review of matrix transpose Question: and matrix multiplication… Can represent dot product as a matrix multiply:

Before we go there – review of matrix transpose

Question:

Page 16: Vectors, Matrices, Rotations - ccs.neu.edu fileBefore we go there – review of matrix transpose Question: and matrix multiplication… Can represent dot product as a matrix multiply:

and matrix multiplication…

Can represent dot product as a matrix multiply:

Page 17: Vectors, Matrices, Rotations - ccs.neu.edu fileBefore we go there – review of matrix transpose Question: and matrix multiplication… Can represent dot product as a matrix multiply:

Same point - different reference frames

xa ˆ

p

5

2

ya ˆ yb ˆ

xb ˆ

8.3

8.3

• for the moment, assume that there is no difference in position…

Page 18: Vectors, Matrices, Rotations - ccs.neu.edu fileBefore we go there – review of matrix transpose Question: and matrix multiplication… Can represent dot product as a matrix multiply:

a

b

)cos()cos(ˆˆ bbabal

yyxx bababa

)cos(ba

Another important use of the dot product: projection

l

Page 19: Vectors, Matrices, Rotations - ccs.neu.edu fileBefore we go there – review of matrix transpose Question: and matrix multiplication… Can represent dot product as a matrix multiply:

p

5

2

8.3

8.3

B-frame’s y axis written in A frame

Think-pair-share

xa

ya

ba x

ba y

Calculate given

Page 20: Vectors, Matrices, Rotations - ccs.neu.edu fileBefore we go there – review of matrix transpose Question: and matrix multiplication… Can represent dot product as a matrix multiply:

Same point - different reference frames

Where:Rotation matrix

Page 21: Vectors, Matrices, Rotations - ccs.neu.edu fileBefore we go there – review of matrix transpose Question: and matrix multiplication… Can represent dot product as a matrix multiply:

Rotation matrices

Rows and columns are unit length and orthogonal

A rotation matrix is a 2x2 or 3x3 matrix R such that:

1.

2.

Right handed coordinate frame

Rotation matrix inverse equals transpose:

Page 22: Vectors, Matrices, Rotations - ccs.neu.edu fileBefore we go there – review of matrix transpose Question: and matrix multiplication… Can represent dot product as a matrix multiply:

Rotation matrices

Rows and columns are unit length and orthogonal

A rotation matrix is a 2x2 or 3x3 matrix R such that:

1.

2.

Right handed coordinate frame

Unit vectors and orthogonal to each other

Page 23: Vectors, Matrices, Rotations - ccs.neu.edu fileBefore we go there – review of matrix transpose Question: and matrix multiplication… Can represent dot product as a matrix multiply:

Rotation matrices

Rows and columns are unit length and orthogonal

A rotation matrix is a 2x2 or 3x3 matrix R such that:

1.

2.

Right handed coordinate frame

Unit vectors and orthogonal to each other

Page 24: Vectors, Matrices, Rotations - ccs.neu.edu fileBefore we go there – review of matrix transpose Question: and matrix multiplication… Can represent dot product as a matrix multiply:

Rotation matrices

By convention:

where

Similarly:

Notice: Because of propertiesof rotation matrix

Page 25: Vectors, Matrices, Rotations - ccs.neu.edu fileBefore we go there – review of matrix transpose Question: and matrix multiplication… Can represent dot product as a matrix multiply:

Think-pair-share

Given:

Calculate:

Page 26: Vectors, Matrices, Rotations - ccs.neu.edu fileBefore we go there – review of matrix transpose Question: and matrix multiplication… Can represent dot product as a matrix multiply:

Example 1: rotation matrix

xa ˆ

ya ˆ

xb ˆ

yb ˆ

a Rb=(a xba yb )=(cos (θ ) −sin (θ )

sin (θ ) cos (θ ) )a xb=(cos (θ )sin (θ ) )

a yb=(−sin (θ )cos (θ ) ) b Ra=(cos (θ ) sin (θ )

−sin (θ ) cos (θ ) )

Page 27: Vectors, Matrices, Rotations - ccs.neu.edu fileBefore we go there – review of matrix transpose Question: and matrix multiplication… Can represent dot product as a matrix multiply:

Example 2: rotation matrix

yA

zA

xA

45

zB

xB

yB

1. Calculate:

2. What’s the magnitude of this rotation?

Page 28: Vectors, Matrices, Rotations - ccs.neu.edu fileBefore we go there – review of matrix transpose Question: and matrix multiplication… Can represent dot product as a matrix multiply:

Example 3: rotation matrix

ax

ay

az

bzbx

by

a Rc=(cθcφ −sθ cθcφ+ π

2

sθ cφ cθ sθ cφ+ π2

sφ 0 sφ+ π

2

)=(cθ cφ −sθ −cθ sφ

sθ cφ cθ −sθ sφ

sφ 0 cφ)

Page 29: Vectors, Matrices, Rotations - ccs.neu.edu fileBefore we go there – review of matrix transpose Question: and matrix multiplication… Can represent dot product as a matrix multiply:

Rotations about x, y, z

R z (α )=(cos ( α ) −sin (α ) 0sin (α ) cos (α ) 0

0 0 1 )R y ( β )=(cos ( β ) 0 sin (β )

0 1 0−sin ( β ) 0 cos ( β ) )

Rx (γ )=(1 0 00 cos ( γ ) −sin (γ )0 sin ( γ ) cos ( γ ) )

These rotation matrices encode the basis vectors of the after-rotation reference frame in terms of the before-rotation reference frame

Page 30: Vectors, Matrices, Rotations - ccs.neu.edu fileBefore we go there – review of matrix transpose Question: and matrix multiplication… Can represent dot product as a matrix multiply:

Remember those double-angle formulas…

sincoscossinsin

sinsincoscoscos