Professional Documents
Culture Documents
Geometric Transformation PDF
Geometric Transformation PDF
2D Translation
Repositioning an object along a straight line path from one coordinate
2D and 3D location to another.
Translation Adding translation distances, tx and ty, to the original coordinate
Rotation position.
Scaling
Rigid-body transformation: x' = x + t x y' = y + t y
Moves object without deformation.
Homogeneous Coordinates
Coordinate Systems y y
Matrix form:
x ' x t x
y' = y + t ,
y
P' = P + T
Before translation x After translation x
x ' s x 0 x
centroids or any other position.
y ' = 0 s y , x' = x s x + x f (1 s x )
xf(1-sx) and yf(1-sy) are constants for all
y points in the object.
y ' = y s y + y f (1 s y )
Before scaling x After scaling x P' = S P
Homogeneous Coordinates Homogeneous Coordinates
A 2D coordinate P1(x1,y1) lying in 3D can be represented as
Problem: P(x,y,z) = P(hx1,hy1,h).
Translation is addition and scaling and rotation are
multiplication of matrices. Given P(m,n,h) in homogeneous coordinates the cartesian coordinates
P' = P + T can be found by P(m/h,n/h,1).
P' = R P
Solved by: P' = S P Each point can have many
Using homogeneous coordinates instead of cartesian different homogeneous
coordinates. Then translation, scaling and rotation can be coordinate representations.
expressed in a general matrix form (multiplication).
2D Translation 2D Rotation
Homogeneous Coordinates Homogeneous Coordinates
x' 1 0 t x x x' cos sin 0 x
Matrix representation: y' = 0 1 t y , P' = T(tx,ty) P Matrix representation: y' = sin cos 0 y ,
y P' = R() P
1 0 0 1 1 1 0 0 1 1
0 0 1 0 0 1 0 0 1 2
0 0 1 0 0 1 0 0 1
2D Scaling Composition of 2D
Homogeneous Coordinates Transformations
x' s x 0 0 x OpenGL provides a rotation function only about the origin.
Matrix representation: y' = 0 s 0 y , P' = S(sx,sy) P
y
To rotate an object about an arbitrary point (pivot point) we
1 0 0 1 1 need to do a sequence of three fundamental transformations.
1. Translate the pivot point to origin.
The inverse scaling matrix is obtained by replacing 2. Rotate about the origin.
sx and sy with 1/sx and 1/sy. 3. Translate the pivot point back to the original position.
Scaling from P to P' to P'': T(x1, y1) R() T(-x1, -y1) =
s x2 0 0 s x1 0 0 s x1 s x2 0 0 x1 (1 cos ) + y1 sin
1 0 x1 cos sin 0 1 0 x1 cos sin
0 0 0 0 = 0 s x1 s x2 0 0 1 y sin cos 0 0 1 y = sin cos
s y2
s y1
y1 (1 cos ) x1 sin
1 1
0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1
1 shx 0 1 0 0
SH x = 0 1 0, SH y = shy 1 0
0 0 1 0 0 1
3D Transformations
Reflection Transformation
3D Translation
Produces a mirror image of an object.
y
x-axis (y = 0) y
xy-plane x' 1 0 0 tx x
1 0 0 Original
1 0 0 y' 0 1 0 t y y P' = T P
0 1 0 0 1 0 A 4 by 4 homogenized matrix = ,
x
x z ' 0 0 1 tz z
0 0 1 1
0 0 1 Reflected 0 0 1 1 0
y-axis (x = 0) y xy-plane y
(x',y',z')
3D Transformation 3D Transformation
3D Scaling 3D Rotation
Scaling with respect to a fixed position Rotation about z-axis Rotation about x-axis
sx 0 0 (1 s x )x f y
cos sin 0 1 0
(1 sy )y f
0 0 0
0 0 cos sin
T( x f , y f , z f ) S( s x , s y , s z ) T( x f , y f , z f ) =
sy 0 sin cos 0 0 0
0 0 sz (1 s z )z f 0 0 1 0 0 sin cos 0
0 0 1 1
0 0 1 0 0 z x 0 0 0
Each row vector in the matrix has 3 properties: Two ways to achieve the transformation:
Composition of 3D Composition of 3D
Transformation Transformation
Create the rotation matrix by using cross product.
R = [r r r ] = 1 2
Done the same way as 2D composition. Rz will rotate into z-axis. T PP
z 1z 2z 3z
P1P2
1. Translate P1 to the origin PP PP
Rx = [r1x r2 x r 3 x ]
Rx will rotate into x-axis.
= 13 1 2
T
2. Rotate about the y-axis (P1,P2 lies in the (y,z) plane)
3. Rotate about the x-axis (P1,P2 lies on the z-axis) P1P3 P1P2
Ry will rotate into y-axis.
Rz Rx
R y = [r1 y r2 y r3 y ] =
4. Rotate about the z-axis (P1,P3 lies in the (y,z) plane) T
Rz Rx
The composite matrix will be r1x r2 x r3 x 0
Composite r1 y r2 y r3 y 0
T ( x1 , y1 , z1 ) = R T
Matrix r1z 0
Rz ( ) Rx ( ) R y ( 90 ) T ( x1 , y1 , z1 )
r2 z r3 z
0 0 0 1
Coordinate Systems
y y
x x
z
Positive rotation is clockwise
Positive rotation gives
counterclockwise rotation