0% found this document useful (0 votes)
40 views

CSE455 6 (2d-Transform)

The document describes the 2D graphics rendering pipeline. It involves several transformation steps: 1. Modeling and viewing transformations move objects from local 3D coordinates to the 3D view scene. 2. Projection transforms map the 3D scene to 2D. Rasterization converts shapes to pixels. 3. 2D transformations like scaling, rotation, translation and shearing are applied to manipulate the 2D scene before rendering the final 2D image. Homogeneous coordinates provide a unified representation for different transformations.

Uploaded by

Ankit Awal
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
40 views

CSE455 6 (2d-Transform)

The document describes the 2D graphics rendering pipeline. It involves several transformation steps: 1. Modeling and viewing transformations move objects from local 3D coordinates to the 3D view scene. 2. Projection transforms map the 3D scene to 2D. Rasterization converts shapes to pixels. 3. 2D transformations like scaling, rotation, translation and shearing are applied to manipulate the 2D scene before rendering the final 2D image. Homogeneous coordinates provide a unified representation for different transformations.

Uploaded by

Ankit Awal
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 32

Graphics Rendering Pipeline

Modeling Viewing
Transformation Transformation
Model 1
M1

Model 2 M2 3DWorld V 3D View


Scene Scene
Mn
Model n

2D
Image
2D Scene Projection
Rasterization
2D Transformation
Scaling

P ( x , y ) → P' ( x' , y ' )


x' = s x x; y ' = sy y
s x 0 
[x , y ] = [x, y ] 
' '

 0 s y 
P ' = P .S
2D Transformation
Scaling

P ( x , y ) → P' ( x' , y ' )


x' = s x x; y ' = sy y
s x 0 
[x , y ] = [x, y ] 
' '

 0 s y 
P ' = P .S
s x = s y : uniform scaling
s x ≠ s y : differential scaling
2D Transformation
Rotation
P ( x , y ) → P' ( x' , y ' )
x = r cos(ö ); y = r sin(ö )
x ' = r cos(ö + è ) P’
y ' = r sin(ö + è )
θ P
x ' = x cos(è ) − y sin(è ) φ
y ' = x sin(è ) + y cos(è )
 cos(è ) sin(è ) 
[x ,y ] = [x,y ] 
' '

 − sin( è ) cos(è ) 
P ' = P .Rè
2D Transformation
General 2x2 Matrix

X → X'
X ' = X .T
a b 
[x , y ] = [x, y ] 
' '
 = [(ax + cy ), (bx + dy )]
c d 

If a = d = 1 and b = c = 0
T = Identity Matrix
X’ = X
2D Transformation
General 2x2 Matrix

If b = c = 0 y
X’ = [ax, dy] : Scaling
P’ P
If b = c = 0 and a = -1, d = 1
X’ = [-x, y] : Reflection

x
2D Transformation
General 2x2 Matrix

 1 0
[x , y ] = [x, y ] 
' '
 = [ x + cy , y ] Shearing in X
c 1
2D Transformation
General 2x2 Matrix

1 b
[x , y ] = [x, y ] 
' '
 = [ x , bx + y ] Shearing in Y
0 1 
2D Transformation
Translation

P(x , y ) → P ' (x ' , y ' ) P’


x ' = x + tx ;y ' = y + ty
P
P = P +T
' T
P = [ x , y ]; T = [t x , t y ]
2D Transformation
Homogenous Coordinates

Scale/Rotate/Reflect/Shear: X’ = XT
Translate: X’ = X + T
P = [x, y ]
Ph = [ x , y , w ]

Multiple values for the same point


e.g., (2, 3, 6) and (4, 6, 12) are same points
2D Transformation
Homogenous Coordinates

w (x, y,w)

(x/w, y/w,1)
w=1
x

y
2D Transformation
Homogenous Coordinates

Unifying representation for transformation


Transformation matrix from 2x2 to 3x3

X → X'
X ' = X .T
a b 0
[ x ' , y ' , w ] = [ x , y ,1] c d 0
 
 l m 1
= [(ax + cy + l ), (bx + dy + m ),1]
2D Transformation
Homogenous Coordinates

Translation
1 0 0
T = 0 1 0
 
 l m 1
X ' = XT
[x', y ' ] = [ x + l, y + m]
2D Transformation
Homogenous Coordinates

Scaling/Rotation/Shear

a b 0
T = c d 0
 
0 0 1
2D Transformation
Homogenous Coordinates
Successive translations: T1 = (l1, m1), T2 = (l2, m2)
After T1 After T1 and T2
1 0 0 1 0 0
X' = X 0 1 0 X'' = X'  0 1 0
   
l1 m1 1 l 2 m2 1
1 0 0  1 0 0  1 0 0
X'' = X  0 1 0  0 1 0 = X  0 1 0
    
l1 m1 1 l 2 m2 1 l1 + l 2 m1 + m2 1
Successive translations are additive
2D Transformation
Homogenous Coordinates
Successive scaling: S1 = (sx1, sy1), S2 = (sx2, sy2)
After S1 After S1 and S2
s x1 0 0 s x 2 0 0
X' = X  0 s y 1 0 X'' = X'  0 sy 2 0
   
 0 0 1  0 0 1
 s x 1 0 0  s x 2 0 0  s x 1s x 2 0 0
X'' = X  0 s y 1 0  0 sy 2 0 = X  0 s y 1s y 2 0
    
 0 0 1  0 0 1  0 0 1
Successive scaling is multiplicative
2D Transformation
Homogenous Coordinates
Successive rotations: R(θ), R(φ)
After R(θ) After R(θ) and R(φ)
 cos è sin è 0  cos ö sin ö 0
X' = X − sin è cos è 0 X'' = X' − sin ö cos ö 0
   
 0 0 1  0 0 1
 cos(è + ö ) sin(è + ö ) 0
X'' = X  − sin(è + ö ) cos(è + ö ) 0
 
 0 0 1
Successive rotations are additive
2D Transformation
Composition of transformation
Rotation about arbitrary point y

Rotation about origin is known

• Translate such that P becomes O P


• Rotate (about O)
• Translate back to P O x
2D Transformation
Composition of transformation
Rotation about arbitrary point y

Rotation about origin is known


P
• Translate such that P becomes O
O x
1 0 0
 
X' = X  0 1 0
− l −m 1
2D Transformation
Composition of transformation
Rotation about arbitrary point y

Rotation about origin is known

• Rotate about O
O x
 cos è sin è 0
X'' = X' − sin è cos è 0
 
 0 0 1
2D Transformation
Composition of transformation
Rotation about arbitrary point y

Rotation about origin is known


P
• Translate back to P
O x
1 0 0
 
X''' = X'' 0 1 0
 l m 1
2D Transformation
Composition of transformation
Composite transformation

1 0 0  cos è sin è 0  1 0 0
   
Xf = X  0 1 0  − sin è cos è 0 0 1 0
 − l −m 1  0 0 1  l m 1

 cos è sin è 0
= X − sin è cos è 0
 
 − m (cos è − 1) + n sin è − n(cos è − 1) − m sin è 1
2D Transformation
Composition of transformation
Reflection about an arbitrary line
B
y
C
A

O x
2D Transformation
Composition of transformation
Reflection about an arbitrary line

y
B
Translation C
A

O x
2D Transformation
Composition of transformation
Reflection about an arbitrary line

y
Rotation B

A C

O x
2D Transformation
Composition of transformation
Reflection about an arbitrary line

y
Reflection

O x
A C

B
2D Transformation
Composition of transformation
Reflection about an arbitrary line

y
Rotation

O A x
B
2D Transformation
Composition of transformation
Reflection about an arbitrary line

y
Translation
C

A
O B x
2D Transformation
Composition of transformation

Given T1 and T2

In general,
T = T1T2 ≠ T2T1
2D Transformation
Rigid Transformations
• Square remains square
• Preserves length and angles
• Sequence of rotations and translations

 r11 r12 0
T = r21 r22 0
 
 l m 1
2D Transformation
Affine Transformations

• Preserves parallelism
• Sequence of rotations, translations, scaling and shear

a b 0 
T = c d 0
 
 l m 1

• Linear transformation is when no translation


2D Transformation
General Transformation

• 3x3 matrix

a b p 
T = c d q 
 
 l m s 

You might also like