vectors, matrices, rotations€¦ · vectors, matrices, rotations. ... 2 5 2 p p. representing...

38
Vectors, Matrices, Rotations

Upload: others

Post on 23-Jul-2020

27 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Vectors, Matrices, Rotations€¦ · Vectors, Matrices, Rotations. ... 2 5 2 p p. Representing Position: vectors p 5 2 The “a” reference frame Basis vectors – unit vectors (length

Vectors, Matrices, Rotations

Page 2: Vectors, Matrices, Rotations€¦ · Vectors, Matrices, Rotations. ... 2 5 2 p p. Representing Position: vectors p 5 2 The “a” reference frame Basis vectors – unit vectors (length

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€¦ · Vectors, Matrices, Rotations. ... 2 5 2 p p. Representing Position: vectors p 5 2 The “a” reference frame Basis vectors – unit vectors (length

Why are we studying this?

Puma 500/560

Page 4: Vectors, Matrices, Rotations€¦ · Vectors, Matrices, Rotations. ... 2 5 2 p p. Representing Position: vectors p 5 2 The “a” reference frame Basis vectors – unit vectors (length

Why are we studying this?

Page 5: Vectors, Matrices, Rotations€¦ · Vectors, Matrices, Rotations. ... 2 5 2 p p. Representing Position: vectors p 5 2 The “a” reference frame Basis vectors – unit vectors (length

Why are we studying this?

Page 6: Vectors, Matrices, Rotations€¦ · Vectors, Matrices, Rotations. ... 2 5 2 p p. Representing Position: vectors p 5 2 The “a” reference frame Basis vectors – unit vectors (length

Representing Position: Vectors

Page 7: Vectors, Matrices, Rotations€¦ · Vectors, Matrices, Rotations. ... 2 5 2 p p. Representing Position: vectors p 5 2 The “a” reference frame Basis vectors – unit vectors (length

Representing Position: vectors

x

y

p

5

2

p=[52 ] (“column” vector)

52p (“row” vector)

x

y

z

2

5

2

p

p

Page 8: Vectors, Matrices, Rotations€¦ · Vectors, Matrices, Rotations. ... 2 5 2 p p. Representing Position: vectors p 5 2 The “a” reference frame Basis vectors – unit vectors (length

Representing Position: vectors

p

5

2The “a” reference frame

Basis vectors– unit vectors (length of magnitude 1)– orthogonal (perpendicular to each other)

Vector p in written in a reference frame

Page 9: Vectors, Matrices, Rotations€¦ · Vectors, Matrices, Rotations. ... 2 5 2 p p. Representing Position: vectors p 5 2 The “a” reference frame Basis vectors – unit vectors (length

What is this unit vector you speak of?

Vector length/magnitude:

Definition of unit vector:

These are the elements of p:

5

2

xb ˆ

yb ˆ

You can turn an arbitrary vector p into a unit vector of the same direction this way:

Page 10: Vectors, Matrices, Rotations€¦ · Vectors, Matrices, Rotations. ... 2 5 2 p p. Representing Position: vectors p 5 2 The “a” reference frame Basis vectors – unit vectors (length

yyxx bababa

)cos(ba

And what does orthogonal mean?

Unit vectors are orthogonal iff (if and only if) the dot product is zero:

is orthogonal to iff

First, define the dot product:

0ba when: 0a

0b

0cos

or,

or, a

b

Page 11: Vectors, Matrices, Rotations€¦ · Vectors, Matrices, Rotations. ... 2 5 2 p p. Representing Position: vectors p 5 2 The “a” reference frame Basis vectors – unit vectors (length

A couple of other random things

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€¦ · Vectors, Matrices, Rotations. ... 2 5 2 p p. Representing Position: vectors p 5 2 The “a” reference frame Basis vectors – unit vectors (length

The importance of differencing two vectors

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

Page 13: Vectors, Matrices, Rotations€¦ · Vectors, Matrices, Rotations. ... 2 5 2 p p. Representing Position: vectors p 5 2 The “a” reference frame Basis vectors – unit vectors (length

The importance of differencing two vectors

b

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

Page 14: Vectors, Matrices, Rotations€¦ · Vectors, Matrices, Rotations. ... 2 5 2 p p. Representing Position: vectors p 5 2 The “a” reference frame Basis vectors – unit vectors (length

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€¦ · Vectors, Matrices, Rotations. ... 2 5 2 p p. Representing Position: vectors p 5 2 The “a” reference frame Basis vectors – unit vectors (length

333231

232221

131211

aaa

aaa

aaa

A

332313

322212

312111

aaa

aaa

aaaTA

333231

232221

131211

aaa

aaa

aaa

2

5p 25Tp

Before we go there – review of matrix transpose

TTT BABA Important property:

Page 16: Vectors, Matrices, Rotations€¦ · Vectors, Matrices, Rotations. ... 2 5 2 p p. Representing Position: vectors p 5 2 The “a” reference frame Basis vectors – unit vectors (length

2221

1211

aa

aaA

2221

1211

bb

bbB

and matrix multiplication…

2222122121221121

2212121121121111

2221

1211

2221

1211

babababa

babababa

bb

bb

aa

aaAB

bab

baabababa T

y

xyxyyxx

Can represent dot product as a matrix multiply:

Page 17: Vectors, Matrices, Rotations€¦ · Vectors, Matrices, Rotations. ... 2 5 2 p p. Representing Position: vectors p 5 2 The “a” reference frame Basis vectors – unit vectors (length

Same point - different reference frames

xa ˆ

p

5

2

ya ˆ yb ˆ

xb ˆ

8.3

8.3

2

5pa

8.3

8.3pb

Page 18: Vectors, Matrices, Rotations€¦ · Vectors, Matrices, Rotations. ... 2 5 2 p p. Representing Position: vectors p 5 2 The “a” reference frame Basis vectors – unit vectors (length

a

b

)cos()cos(ˆˆ bbabal

Another important use of the dot product: projection

l

Page 19: Vectors, Matrices, Rotations€¦ · Vectors, Matrices, Rotations. ... 2 5 2 p p. Representing Position: vectors p 5 2 The “a” reference frame Basis vectors – unit vectors (length

a

b

)cos()cos(ˆˆ bbabal

Another important use of the dot product: projection

l

Another way of writing the dot product

Page 20: Vectors, Matrices, Rotations€¦ · Vectors, Matrices, Rotations. ... 2 5 2 p p. Representing Position: vectors p 5 2 The “a” reference frame Basis vectors – unit vectors (length

p

5

2

8.3

8.3

B-frame’s x axis written in A frame

B-frame’s y axis written in A frame

Same point - different reference frames

xa

ya

ba x

ba y

Page 21: Vectors, Matrices, Rotations€¦ · Vectors, Matrices, Rotations. ... 2 5 2 p p. Representing Position: vectors p 5 2 The “a” reference frame Basis vectors – unit vectors (length

xa

pa

5

2

ya

8.3

8.3

ba x

ba y B-frame’s y axis written

in A frame

Same point - different reference frames

B-frame’s x axis written in A frame

Page 22: Vectors, Matrices, Rotations€¦ · Vectors, Matrices, Rotations. ... 2 5 2 p p. Representing Position: vectors p 5 2 The “a” reference frame Basis vectors – unit vectors (length

5

2

8.3

8.3

B-frame’s y axis written in A frame

Same point - different reference frames

xa

pa

ya

ba x

ba y

B-frame’s x axis written in A frame

Page 23: Vectors, Matrices, Rotations€¦ · Vectors, Matrices, Rotations. ... 2 5 2 p p. Representing Position: vectors p 5 2 The “a” reference frame Basis vectors – unit vectors (length

xA

p

5

2

yA

8.3

8.3

BA x

BA y

Same point - different reference frames

where:

or

Page 24: Vectors, Matrices, Rotations€¦ · Vectors, Matrices, Rotations. ... 2 5 2 p p. Representing Position: vectors p 5 2 The “a” reference frame Basis vectors – unit vectors (length

The rotation matrix

To recap:

where:

Page 25: Vectors, Matrices, Rotations€¦ · Vectors, Matrices, Rotations. ... 2 5 2 p p. Representing Position: vectors p 5 2 The “a” reference frame Basis vectors – unit vectors (length

The rotation matrix

To recap:

where:

We will write:

so:

Notice the way the notation “cancels out”

But, can we do this: ???

Page 26: Vectors, Matrices, Rotations€¦ · Vectors, Matrices, Rotations. ... 2 5 2 p p. Representing Position: vectors p 5 2 The “a” reference frame Basis vectors – unit vectors (length

The rotation matrix

Multiply both sides by inverse:

But, can we do this: ???

It turns out that:

because the columns of are unit, orthogonal

Page 27: Vectors, Matrices, Rotations€¦ · Vectors, Matrices, Rotations. ... 2 5 2 p p. Representing Position: vectors p 5 2 The “a” reference frame Basis vectors – unit vectors (length

The rotation matrix

Multiply both sides by inverse:

But, can we do this: ???

It turns out that:

because the columns of are orthogonal

This is important!

Page 28: Vectors, Matrices, Rotations€¦ · Vectors, Matrices, Rotations. ... 2 5 2 p p. Representing Position: vectors p 5 2 The “a” reference frame Basis vectors – unit vectors (length

The rotation matrix

So, if:

Then:

Page 29: Vectors, Matrices, Rotations€¦ · Vectors, Matrices, Rotations. ... 2 5 2 p p. Representing Position: vectors p 5 2 The “a” reference frame Basis vectors – unit vectors (length

The rotation matrix

Both columns are orthogonal

But:

So, the rows are orthogonal too!

Page 30: Vectors, Matrices, Rotations€¦ · Vectors, Matrices, Rotations. ... 2 5 2 p p. Representing Position: vectors p 5 2 The “a” reference frame Basis vectors – unit vectors (length

The rotation matrix

Both columns are orthogonal

But:

So, the rows are orthogonal too!

The same matrix can be understood both ways!

Page 31: Vectors, Matrices, Rotations€¦ · Vectors, Matrices, Rotations. ... 2 5 2 p p. Representing Position: vectors p 5 2 The “a” reference frame Basis vectors – unit vectors (length

Example 1: rotation matrix

xa ˆ

ya ˆ

xb ˆ

yb ˆ

cossin

sincosˆˆ b

ab

ab

a yxR

sin

cosˆb

a x

cos

sinˆb

a y

cossin

sincosa

bR

Page 32: Vectors, Matrices, Rotations€¦ · Vectors, Matrices, Rotations. ... 2 5 2 p p. Representing Position: vectors p 5 2 The “a” reference frame Basis vectors – unit vectors (length

Example 2: rotation matrix

yA

zA

xA

45

zB

xB

yB

BA

BA

BA

BA zyxR ˆˆˆ

21

21

21

21

0

0

1

0

0BAR

21

21

21

21

0

010

0

BAR

Page 33: Vectors, Matrices, Rotations€¦ · Vectors, Matrices, Rotations. ... 2 5 2 p p. Representing Position: vectors p 5 2 The “a” reference frame Basis vectors – unit vectors (length

Example 3: rotation matrix

ax

ay

az

bzbx

by

cs

ssccs

scscc

ss

csccs

ccscc

Rca

002

2

2

Page 34: Vectors, Matrices, Rotations€¦ · Vectors, Matrices, Rotations. ... 2 5 2 p p. Representing Position: vectors p 5 2 The “a” reference frame Basis vectors – unit vectors (length

Rotations about x, y, z

100

0cossin

0sincos

zR

cos0sin

010

sin0cos

yR

cossin0

sincos0

001

xR

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

Page 35: Vectors, Matrices, Rotations€¦ · Vectors, Matrices, Rotations. ... 2 5 2 p p. Representing Position: vectors p 5 2 The “a” reference frame Basis vectors – unit vectors (length

Remember those double-angle formulas…

sincoscossinsin

sinsincoscoscos

Page 36: Vectors, Matrices, Rotations€¦ · Vectors, Matrices, Rotations. ... 2 5 2 p p. Representing Position: vectors p 5 2 The “a” reference frame Basis vectors – unit vectors (length

Example 1: composition of rotation matrices

CB

BA

CA RRR

p

ya ˆ

xb ˆ

yb ˆ

xa ˆ

yc ˆ

xc ˆ

12

21212121

21212121

22

22

11

11

cossin

sincos

cossin

sincos

ssccsccs

csscssccRc

a

1212

1212

cs

sc

Page 37: Vectors, Matrices, Rotations€¦ · Vectors, Matrices, Rotations. ... 2 5 2 p p. Representing Position: vectors p 5 2 The “a” reference frame Basis vectors – unit vectors (length

Example 2: composition of rotation matrices

ax

ay

az

bx

cx

100

0

0

cs

sc

Rba

cs

sc

cs

sc

Rcb

0

010

0

0

010

0

Page 38: Vectors, Matrices, Rotations€¦ · Vectors, Matrices, Rotations. ... 2 5 2 p p. Representing Position: vectors p 5 2 The “a” reference frame Basis vectors – unit vectors (length

Example 2: composition of rotation matrices

ax

ay

az

bx

cx

cs

ssccs

scscc

cs

sc

cs

sc

RRR cb

ba

ca

00

010

0

100

0

0