38
5554: Packet 8 1 Coordinate transformations

Coordinate transformations - University of Nevada, Las Vegaspushkin.faculty.unlv.edu/ece5554/08_Coordinate... · 2006. 11. 14. · 5554: Packet 8 2 Overview •Rigid transformations

  • Upload
    others

  • View
    5

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Coordinate transformations - University of Nevada, Las Vegaspushkin.faculty.unlv.edu/ece5554/08_Coordinate... · 2006. 11. 14. · 5554: Packet 8 2 Overview •Rigid transformations

5554: Packet 8 1

Coordinate transformations

Page 2: Coordinate transformations - University of Nevada, Las Vegaspushkin.faculty.unlv.edu/ece5554/08_Coordinate... · 2006. 11. 14. · 5554: Packet 8 2 Overview •Rigid transformations

5554: Packet 8 2

Overview• Rigid transformations are the

simplest§Translation, rotation§Preserve sizes and angles

• Affine transformation is the most general linear case

• Homogeneous coordinatesallow for convenient matrix representation

Page 3: Coordinate transformations - University of Nevada, Las Vegaspushkin.faculty.unlv.edu/ece5554/08_Coordinate... · 2006. 11. 14. · 5554: Packet 8 2 Overview •Rigid transformations

5554: Packet 8 3

2D coordinate transformations

Page 4: Coordinate transformations - University of Nevada, Las Vegaspushkin.faculty.unlv.edu/ece5554/08_Coordinate... · 2006. 11. 14. · 5554: Packet 8 2 Overview •Rigid transformations

5554: Packet 8 4

Translation

( ),T

x yt t

( ), Tx y′ ′

x

y

( ), Tx y

x

y

tx xty y

′ = + ′

Page 5: Coordinate transformations - University of Nevada, Las Vegaspushkin.faculty.unlv.edu/ece5554/08_Coordinate... · 2006. 11. 14. · 5554: Packet 8 2 Overview •Rigid transformations

5554: Packet 8 5

Two interpretations• Translate a point§… relative to the given coordinate system§= vector addition

• Find the point's location relative to a new coordinate system

Page 6: Coordinate transformations - University of Nevada, Las Vegaspushkin.faculty.unlv.edu/ece5554/08_Coordinate... · 2006. 11. 14. · 5554: Packet 8 2 Overview •Rigid transformations

5554: Packet 8 6

( ),T

x yt t− −

x

y

( ),T

x y

x′

y′

x

y

tx xty y

′ = + ′

Page 7: Coordinate transformations - University of Nevada, Las Vegaspushkin.faculty.unlv.edu/ece5554/08_Coordinate... · 2006. 11. 14. · 5554: Packet 8 2 Overview •Rigid transformations

5554: Packet 8 7

Rotation

θ ( ), Tx y

( ), Tx y′ ′

x

y

r

r

cos sinsin cos

x xy y

θ θθ θ

′ − = ′

Page 8: Coordinate transformations - University of Nevada, Las Vegaspushkin.faculty.unlv.edu/ece5554/08_Coordinate... · 2006. 11. 14. · 5554: Packet 8 2 Overview •Rigid transformations

5554: Packet 8 8

θϕ

( ), Tx y

( ), Tx y′ ′

x

y

r

r

2 2r x y= +

( ) ( )( ) ( )

cos cos cos sin sinsin sin cos cos sin

x r ry r r

ϕ θ ϕ θ ϕ θϕ θ ϕ θ ϕ θ

′ = + = −′ = + = +

Solve for x' and y' :

Page 9: Coordinate transformations - University of Nevada, Las Vegaspushkin.faculty.unlv.edu/ece5554/08_Coordinate... · 2006. 11. 14. · 5554: Packet 8 2 Overview •Rigid transformations

5554: Packet 8 9

( )( )

cos cos cos sin sinsin sin cos cos sin

x r r ry r r r

ϕ θ ϕ θ ϕ θϕ θ ϕ θ ϕ θ

′ = + = −′ = + = +

cos sinsin cos

x x yy x y

θ θθ θ

′ = −′ = +

cossin

x ry r

ϕϕ

==

Combine:

Solve for x and y:

Page 10: Coordinate transformations - University of Nevada, Las Vegaspushkin.faculty.unlv.edu/ece5554/08_Coordinate... · 2006. 11. 14. · 5554: Packet 8 2 Overview •Rigid transformations

5554: Packet 8 10

Two interpretations• Rotate a point relative to the

given coordinate system• Find the point's location relative

to a new coordinate system(rotated about the origin of the original coordinate system)

Page 11: Coordinate transformations - University of Nevada, Las Vegaspushkin.faculty.unlv.edu/ece5554/08_Coordinate... · 2006. 11. 14. · 5554: Packet 8 2 Overview •Rigid transformations

5554: Packet 8 11

θ

x

y y′

x′

θ

p

cos sinsin cos

x xy y

θ θθ θ

′ − = ′

Page 12: Coordinate transformations - University of Nevada, Las Vegaspushkin.faculty.unlv.edu/ece5554/08_Coordinate... · 2006. 11. 14. · 5554: Packet 8 2 Overview •Rigid transformations

5554: Packet 8 12

Translation and rotation combined

cos sinsin cos

x

y

tx xty y

θ θθ θ

′ − = + ′

One interpretation:Rotate the point (x, y) by the angle θ about the origin (counterclockwise if θ > 0),then translate by ( ),

T

x yt t

Page 13: Coordinate transformations - University of Nevada, Las Vegaspushkin.faculty.unlv.edu/ece5554/08_Coordinate... · 2006. 11. 14. · 5554: Packet 8 2 Overview •Rigid transformations

5554: Packet 8 13

Another interpretation:Transform point locations to a new coordinate system that is translated by and then rotated by angle θ(clockwise if θ > 0)

( ),T

x yt t− −

Page 14: Coordinate transformations - University of Nevada, Las Vegaspushkin.faculty.unlv.edu/ece5554/08_Coordinate... · 2006. 11. 14. · 5554: Packet 8 2 Overview •Rigid transformations

5554: Packet 8 14

If several points are involved, then the distance between each pair of points remains the same;

this is an example of rigid transformation

Page 15: Coordinate transformations - University of Nevada, Las Vegaspushkin.faculty.unlv.edu/ece5554/08_Coordinate... · 2006. 11. 14. · 5554: Packet 8 2 Overview •Rigid transformations

5554: Packet 8 15

Homogeneous coordinate

representationReRe--write matrix write matrix

multiplication and multiplication and additionaddition

Page 16: Coordinate transformations - University of Nevada, Las Vegaspushkin.faculty.unlv.edu/ece5554/08_Coordinate... · 2006. 11. 14. · 5554: Packet 8 2 Overview •Rigid transformations

5554: Packet 8 16

We can write this another way:

cos sinsin cos

x

y

tx xty y

θ θθ θ

′ − = + ′

cos sinsin cos

1 0 0 1 1

x

y

x t xy t y

θ θθ θ

′ − ′ =

Page 17: Coordinate transformations - University of Nevada, Las Vegaspushkin.faculty.unlv.edu/ece5554/08_Coordinate... · 2006. 11. 14. · 5554: Packet 8 2 Overview •Rigid transformations

5554: Packet 8 17

Homogeneous coordinates• Re-write matrix multiplication and

addition as multiplication alone• Must increase the dimensionality

by 1• Primary motivation: simplifies a

sequence of transformations

Page 18: Coordinate transformations - University of Nevada, Las Vegaspushkin.faculty.unlv.edu/ece5554/08_Coordinate... · 2006. 11. 14. · 5554: Packet 8 2 Overview •Rigid transformations

5554: Packet 8 18

2 1

1 1n

x xy M M M y

′ ′ =

L

1 1

x xy M y

′ ′ =

(Associative, but not commutative)

Page 19: Coordinate transformations - University of Nevada, Las Vegaspushkin.faculty.unlv.edu/ece5554/08_Coordinate... · 2006. 11. 14. · 5554: Packet 8 2 Overview •Rigid transformations

5554: Packet 8 19

2D affine transformation

• Most general linear transformation involving 2 variables

• Translation and rotation are special cases of this

11 12 13

21 22 23

x a x a y ay a x a y a

′ = + +′ = + +

Page 20: Coordinate transformations - University of Nevada, Las Vegaspushkin.faculty.unlv.edu/ece5554/08_Coordinate... · 2006. 11. 14. · 5554: Packet 8 2 Overview •Rigid transformations

5554: Packet 8 20

2D affine transformation(homogeneous form)

11 12 13

21 22 23

1 0 0 1 1

x a a a xy a a a y

′ ′ =

Page 21: Coordinate transformations - University of Nevada, Las Vegaspushkin.faculty.unlv.edu/ece5554/08_Coordinate... · 2006. 11. 14. · 5554: Packet 8 2 Overview •Rigid transformations

5554: Packet 8 21

0 00 0

1 0 0 1 1

x

y

x s xy s y

′ ′ =

Scaling

Page 22: Coordinate transformations - University of Nevada, Las Vegaspushkin.faculty.unlv.edu/ece5554/08_Coordinate... · 2006. 11. 14. · 5554: Packet 8 2 Overview •Rigid transformations

5554: Packet 8 22

Similarity transformation

00

1 0 0 1 1

x a b xy b a y

′ − ′ =

• Rotates and scales• Angles are preserved

Page 23: Coordinate transformations - University of Nevada, Las Vegaspushkin.faculty.unlv.edu/ece5554/08_Coordinate... · 2006. 11. 14. · 5554: Packet 8 2 Overview •Rigid transformations

5554: Packet 8 23

Shear in x-direction

1 00 1 0

1 0 0 1 1

xx k xy y

′ ′ =

Page 24: Coordinate transformations - University of Nevada, Las Vegaspushkin.faculty.unlv.edu/ece5554/08_Coordinate... · 2006. 11. 14. · 5554: Packet 8 2 Overview •Rigid transformations

5554: Packet 8 24

Shear in y-direction

1 0 01 0

1 0 0 1 1y

x xy k y

′ ′ =

Page 25: Coordinate transformations - University of Nevada, Las Vegaspushkin.faculty.unlv.edu/ece5554/08_Coordinate... · 2006. 11. 14. · 5554: Packet 8 2 Overview •Rigid transformations

5554: Packet 8 25

Reflection about x-axis

1 0 00 1 0

1 0 0 1 1

x xy y

′ ′ = −

Page 26: Coordinate transformations - University of Nevada, Las Vegaspushkin.faculty.unlv.edu/ece5554/08_Coordinate... · 2006. 11. 14. · 5554: Packet 8 2 Overview •Rigid transformations

5554: Packet 8 26

Mapping 3D to 2D

0 00 00 0 1

sx f xsy f ys z

′ ′ =

Solve for x' and y' by eliminating sDoes this look familiar?

Page 27: Coordinate transformations - University of Nevada, Las Vegaspushkin.faculty.unlv.edu/ece5554/08_Coordinate... · 2006. 11. 14. · 5554: Packet 8 2 Overview •Rigid transformations

5554: Packet 8 27

• 2D affine transformation

• Planar perspective projection

11 12 13

21 22 23

1 0 0 1 1

x a a a xy a a a y

′ ′ =

11 12 13

21 22 23

31 32 1 1

sx a a a xs y a a a ys a a

′ ′ =

Page 28: Coordinate transformations - University of Nevada, Las Vegaspushkin.faculty.unlv.edu/ece5554/08_Coordinate... · 2006. 11. 14. · 5554: Packet 8 2 Overview •Rigid transformations

5554: Packet 8 28

An application: image warping

• Create a new image Inew from a given image I using arbitrary mappings g and h:

• Example: rotation

( ) ( ) ( )( ), , , ,newI x y I g x y h x y=

( )( )

, cos sin, sin cos

g x y x yh x y x y

θ θθ θ

= −= +

Page 29: Coordinate transformations - University of Nevada, Las Vegaspushkin.faculty.unlv.edu/ece5554/08_Coordinate... · 2006. 11. 14. · 5554: Packet 8 2 Overview •Rigid transformations

5554: Packet 8 29

Higher-order (quadratic, cubic) mappings are common

Page 30: Coordinate transformations - University of Nevada, Las Vegaspushkin.faculty.unlv.edu/ece5554/08_Coordinate... · 2006. 11. 14. · 5554: Packet 8 2 Overview •Rigid transformations

5554: Packet 8 30

3D coordinate transformations

Page 31: Coordinate transformations - University of Nevada, Las Vegaspushkin.faculty.unlv.edu/ece5554/08_Coordinate... · 2006. 11. 14. · 5554: Packet 8 2 Overview •Rigid transformations

5554: Packet 8 31

3D translation

x

y

z

x x ty y tz z t

′ ′ = + ′

Page 32: Coordinate transformations - University of Nevada, Las Vegaspushkin.faculty.unlv.edu/ece5554/08_Coordinate... · 2006. 11. 14. · 5554: Packet 8 2 Overview •Rigid transformations

5554: Packet 8 32

Rotation• about z axis

• about x axis

cos sin 0sin cos 0

0 0 1

x xy yz z

θ θθ θ

′ − ′ = ′

1 0 00 cos sin0 sin cos

x xy yz z

θ θθ θ

′ ′ = − ′

Page 33: Coordinate transformations - University of Nevada, Las Vegaspushkin.faculty.unlv.edu/ece5554/08_Coordinate... · 2006. 11. 14. · 5554: Packet 8 2 Overview •Rigid transformations

5554: Packet 8 33

Rotation• about y axis

cos 0 sin0 1 0

sin 0 cos

x xy yz z

θ θ

θ θ

′ ′ = ′ −

Page 34: Coordinate transformations - University of Nevada, Las Vegaspushkin.faculty.unlv.edu/ece5554/08_Coordinate... · 2006. 11. 14. · 5554: Packet 8 2 Overview •Rigid transformations

5554: Packet 8 34

Rotationabout arbitrary axis through the origin:

11 12 13

21 22 23

31 32 33

x u u u xy u u u yz u u u z

′ ′ = ′

( )1 11 12 13, , Tu u u=u is a unit vectorin the direction of the new x-axis (etc.)

Page 35: Coordinate transformations - University of Nevada, Las Vegaspushkin.faculty.unlv.edu/ece5554/08_Coordinate... · 2006. 11. 14. · 5554: Packet 8 2 Overview •Rigid transformations

5554: Packet 8 35

Homogeneous coordinates• Arbitrary 3D rigid transformation:

11 12 13

21 22 23

31 32 33

1 0 0 0 1 1

x

y

z

x u u u t xy u u u t yz u u u t z

′ ′ = ′

Page 36: Coordinate transformations - University of Nevada, Las Vegaspushkin.faculty.unlv.edu/ece5554/08_Coordinate... · 2006. 11. 14. · 5554: Packet 8 2 Overview •Rigid transformations

5554: Packet 8 36

• This can be abbreviated as follows:

11 1

T

x xRy y

z z

′ ′ = ′

t

0

Page 37: Coordinate transformations - University of Nevada, Las Vegaspushkin.faculty.unlv.edu/ece5554/08_Coordinate... · 2006. 11. 14. · 5554: Packet 8 2 Overview •Rigid transformations

5554: Packet 8 37

3D affine transformation

11 12 13 14

21 22 23 24

31 32 33 34

1 0 0 0 1 1

x a a a a xy a a a a yz a a a a z

′ ′ = ′

Page 38: Coordinate transformations - University of Nevada, Las Vegaspushkin.faculty.unlv.edu/ece5554/08_Coordinate... · 2006. 11. 14. · 5554: Packet 8 2 Overview •Rigid transformations

5554: Packet 8 38

Summary

• Coordinate transformations(2D and 3D) have many applications

• Image warping is very common• Affine transformation is the

most general linear case• Homogeneous coordinates

allow for convenient matrix representation