2D & 3D Transformations
2D & 3D Transformations
Computer Graphics
Presentation by
R.Sakthivel Murugan,
AP/Mech,
KCET.
Coordinate Systems
• World Coordinate System
• Object Coordinate System
• Hierarchical Coordinate Systems
• Viewpoint Coordinate System
• Model Window Coordinate System
• Screen Coordinate System
• Viewport Coordinate System
World Coordinate System
• Also known as the "universe" or sometimes
"model" coordinate system.
• This is the base reference system for the overall
model, ( generally in 3D ), to which all other
model coordinates relate.
(tx,ty)
(x,y)
y
P' P T
T TransformationMatrix
2D Rotation
P’
Sy
x' s x x
y' s y y
y
x' s x 0 x
y ' 0 s y y
x , yf
P' S P
f
x
S-> Scale factor
2D Reflections
y y y
x x
Reflection about X axis Reflection about Y axis Reflection about X & Y axis
P ( x, y ) P ( x, y ) P ( x, y )
P ' ( x' , y ' ) [ X ,Y ] P' ( x' , y ' ) [ X , Y ] P ' ( x' , y ' ) [ X ,Y ]
1 0 x 1 0 x 1 0 x
P' P' P'
0 1 y 0 1 y 0 1 y
P ' Pm P P ' Rm P P' Z m P
Specifying 2D Transformations
• Translation
– T(tx, ty)
– Translation distances
• Scale
– S(sx,sy)
– Scale factors
• Rotation
– R()
– Rotation angle
Homogeneous Coordinates
w
x
• The fact that all the points along each line can
be mapped back to the same point in 2D gives
this coordinate system its name – homogeneous
coordinates.
x 1 0 t x x
y 0 1 t y , P T t , t P
2D Translation
y x y
1 0 0 1 1
x cos sin 0 x
2D Rotation y sin cos 0 y , P R P
1 0 0 1 1
x S x 0 0 x
2D Scaling y 0 Sy 0 y , P S S x , S y P
1 0 0 1 1
Composite transformations
• More complex geometric & coordinate transformation
can be built from the basic transformation by using the
process of composition of function.
1 0 t x cos sin 0 1 S x 0 0
T1 0 1 t y , R 1 sin cos 0 , S 1 0 1 S y 0
0 0 1 0 0 1 0 0 1
Composite transformations: P M2 M1 P M2 M1 P M P
P T t2 x , t2 y T t1x , t1 y P T t2 x , t2 y T t1x , t1 y P
1 0 t2 x 1 0 t1x 1 0 t1x t2 x
0 1 t 0 1 t 0 1 t t
Composite translations: 2y 1y 1y 2y
T t2 x , t2 y T t1x , t1 y T t1x t2 x , t1 y t2 y
P R 2 R 1 P R 2 R 1 P
P R 1 2 P
S2 x 0 0 S1x 0 0 S1x S2 x 0 0
0 S2 y 0 0 S1 y 0 0 S1 y S2 y 0
0 0 1 0 0 1 0 0 1
Translation x x t x
y
y y t y
z z tz
y y S y
z x S z
z x z x
Enlarging object also moves it from origin
x S x 0 0 0 x
y 0 Sy 0 0 y
P SP
z 0 0 Sz 0 z
1 0 0 0 1 1
3D Rotations
x' 1 0 0 0 x
y ' 0 Cos Sin 0 y
Rotation about X-axis ( Y-Z Plane) P'
z ' 0 Sin Cos
0 z
1 0 0 0 1 1