Coordinate transformations 5554: Packet 8 1
Overview Rigid transformations are the simplest Translation, rotation Preserve sizes and angles Affine transformation is the most general linear case Homogeneous coordinates allow for convenient matrix representation 5554: Packet 8 2
2D coordinate transformations 5554: Packet 8 3
Translation y ( x, y ) T ( t, ) x ty T ( xy, ) T x x x t x = + y y t y 5554: Packet 8 4
Two interpretations Translate a point relative to the given coordinate system = vector addition Find the point's location relative to a new coordinate system 5554: Packet 8 5
y y x x t x = + y y t y ( xy, ) T x ( t, ) x ty T 5554: Packet 8 6 x
y Rotation r ( x, y ) T x cosθ sinθ x = y sinθ cosθ y θ r ( xy, ) T x 5554: Packet 8 7
y r ( x, y ) T r = x 2 + y 2 θ ϕ r ( xy, ) T x Solve for x' and y' : x = rcos + = r cos cos sin sin ( ϕ θ) ( ϕ θ ϕ θ) y = rsin + = r sin cos + cos sin ( ϕ θ) ( ϕ θ ϕ θ) 5554: Packet 8 8
x = rcos ϕ + θ = rcosϕcosθ rsinϕsinθ ( ) ( ) y = rsin ϕ + θ = rsinϕcosθ + rcosϕsinθ Solve for x and y: x = r cosϕ y = r sinϕ Combine: x = xcosθ ysinθ y = xsinθ + ycosθ 5554: Packet 8 9
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) 5554: Packet 8 10
y y θ x cosθ sinθ x = y sinθ cosθ y p θ x x 5554: Packet 8 11
Translation and rotation combined x cosθ sinθ x t x = + y sinθ cosθ y t y One interpretation: Rotate the point (x, y) by the angle θ about the origin (counterclockwise if θ > 0), then translate by ( t, ) x ty T 5554: Packet 8 12
Another interpretation: Transform point locations to a new coordinate system that is translated by ( t, ) x ty and then rotated by angle θ (clockwise if θ > 0) T 5554: Packet 8 13
If several points are involved, then the distance between each pair of points remains the same; this is an example of rigid transformation 5554: Packet 8 14
Homogeneous coordinate representation Re-write matrix multiplication and addition 5554: Packet 8 15
x cosθ sinθ x t x = + y sinθ cosθ y t y We can write this another way: x cosθ sinθ t x x y = sinθ cosθ t y y 1 0 0 1 1 5554: Packet 8 16
Homogeneous coordinates Re-write matrix multiplication and addition as multiplication alone Must increase the dimensionality by 1 Primary motivation: simplifies a sequence of transformations 5554: Packet 8 17
x x y = M MM y n 2 1 1 1 x x y = M y (Associative, but not commutative) 1 1 5554: Packet 8 18
2D affine transformation x = a x + a y + a 11 12 13 y = a x + a y + a 21 22 23 Most general linear transformation involving 2 variables Translation and rotation are special cases of this 5554: Packet 8 19
2D affine transformation (homogeneous form) x a a a x 11 12 13 y = a a a y 21 22 23 1 0 0 1 1 5554: Packet 8 20
Scaling x s 0 0 x x y = 0 s 0 y y 1 0 0 1 1 5554: Packet 8 21
Similarity transformation x a b 0 x y = b a 0 y 1 0 0 1 1 Rotates and scales Angles are preserved 5554: Packet 8 22
Shear in x-direction x 1 k 0 x x y = 0 1 0 y 1 0 0 1 1 5554: Packet 8 23
Shear in y-direction x 1 0 0 x y = k 1 0 y y 1 0 0 1 1 5554: Packet 8 24
Reflection about x-axis x 1 0 0 x y = 0 1 0 y 1 0 0 1 1 5554: Packet 8 25
Mapping 3D to 2D sx f 0 0 x sy = 0 f 0 y s 0 0 1 z Solve for x' and y' by eliminating s Does this look familiar? 5554: Packet 8 26
2D affine transformation x a a a x 11 12 13 y = a a a y 21 22 23 1 0 0 1 1 Planar perspective projection sx a a a x 11 12 13 sy = a a a y 21 22 23 s a a 1 1 31 32 5554: Packet 8 27
An application: image warping Create a new image Inew from a given image I using arbitrary mappings g and h: new ( ) (, ) (, ), (, ) I xy = I g xy h xy Example: rotation g xy, = xcosθ ysinθ ( ) ( ) h xy, = xsinθ + ycosθ 5554: Packet 8 28
Higher-order (quadratic, cubic) mappings are common 5554: Packet 8 29
3D coordinate transformations 5554: Packet 8 30
3D translation x x t x y = y + t y z z t z 5554: Packet 8 31
about z axis about x axis Rotation x cosθ sinθ 0 x y = sinθ cosθ 0 y z 0 0 1 z x 1 0 0 x y = 0 cosθ sinθ y z 0 sinθ cosθ z 5554: Packet 8 32
about y axis Rotation x cosθ 0 sinθ x y = 0 1 0 y z sinθ 0 cosθ z 5554: Packet 8 33
Rotation about arbitrary axis through the origin: u = x u u u x 11 12 13 y = u u u y 21 22 23 z u u u z 31 32 33 ( u, u, u ) 1 11 12 13 T is a unit vector in the direction of the new x-axis (etc.) 5554: Packet 8 34
Homogeneous coordinates Arbitrary 3D rigid transformation: x u u u t x 11 12 13 x y u u u t y = 21 22 23 y z u u u t z 31 32 33 z 1 0 0 0 1 1 5554: Packet 8 35
This can be abbreviated as follows: x x y R t y = z T 1 z 0 1 1 5554: Packet 8 36
3D affine transformation x a a a a x 11 12 13 14 y a a a a y = 21 22 23 24 z a a a a z 31 32 33 34 1 0 0 0 1 1 5554: Packet 8 37
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 5554: Packet 8 38