Padhaiko › Subjects › Computer Graphics and Visualization › Past exam questions › 2081 Chaitra (Regular) Q3(a) Past exam question: 2081 Chaitra (Regular), Q3(a) Computer Graphics and Visualization · 4 marks
Open in the Padhaiko app Topic: 2D & Composite Transformations; Window-to-Viewport
Question Suppose there is a rectangle whose coordinates are A(1,1), B(4,1), C(4,4), D(1,4) and the window coordinates are (2,2), (5,2), (5,5), (2,5) and the given viewport location is (0.5,0), (1,0), (1,0.5), (0.5,0.5). Calculate the viewing transformation.
Solution Identification of Window and Viewport Extents: From the given boundaries:
Clipping Window Extents: Corners ( 2 , 2 ) , ( 5 , 2 ) , ( 5 , 5 ) , ( 2 , 5 )
x w m i n x w m a x ⟹ W w = 2 , = 5 = x w m a x − x w m i n = 5 − 2 = 3
y w m i n y w m a x ⟹ H w = 2 , = 5 = y w m a x − y w m i n = 5 − 2 = 3
Viewport Extents: Corners ( 0.5 , 0 ) , ( 1 , 0 ) , ( 1 , 0.5 ) , ( 0.5 , 0.5 )
x v m i n x v m a x ⟹ W v = 0.5 , = 1.0 = x v m a x − x v m i n = 1.0 − 0.5 = 0.5
y v m i n y v m a x ⟹ H v = 0 , = 0.5 = y v m a x − y v m i n = 0.5 − 0 = 0.5
Viewing Transformation Equations and Matrix: The window-to-viewport coordinate mapping equations maintain relative position:
x v m a x − x v m i n x v − x v m i n = x w m a x − x w m i n x w − x w m i n ⟹ x v = x v m i n + ( x w − x w m i n ) S x
y v m a x − y v m i n y v − y v m i n = y w m a x − y w m i n y w − y w m i n ⟹ y v = y v m i n + ( y w − y w m i n ) S y
Substituting the numerical parameters:
x v = 0.5 + ( x w − 2 ) ⋅ 6 1 = 2 1 + 6 x w − 2 = 6 x w + 1
y v = 0 + ( y w − 2 ) ⋅ 6 1 = 6 y w − 2
The composite viewing transformation matrix M w → v = T ( x v m i n , y v m i n ) ⋅ S ( S x , S y ) ⋅ T ( − x w m i n , − y w m i n ) :
Transforming the Given Rectangle Vertices: Applying the transformation equations to the vertices A ( 1 , 1 ) , B ( 4 , 1 ) , C ( 4 , 4 ) , and D ( 1 , 4 ) :
For A ( 1 , 1 ) :
x v A = 6 1 + 1 = 6 2 = 3 1 ≈ 0.3333
y v A = 6 1 − 2 = − 6 1 ≈ − 0.1667 ⟹ A ′ ( 3 1 , − 6 1 )
For B ( 4 , 1 ) :
y v B = 6 1 − 2 = − 6 1 ≈ − 0.1667 ⟹ B ′ ( 6 5 , − 6 1 )
For C ( 4 , 4 ) :
y v C = 6 4 − 2 = 6 2 = 3 1 ≈ 0.3333 ⟹ C ′ ( 6 5 , 3 1 )
For D ( 1 , 4 ) :
x v D = 6 1 + 1 = 6 2 = 3 1 ≈ 0.3333
y v D = 6 4 − 2 = 6 2 = 3 1 ≈ 0.3333 ⟹ D ′ ( 3 1 , 3 1 )
Answer: The window-to-viewport transformation matrix is:
with mapping formulas x v = 6 x w + 1 and y v = 6 y w − 2 . The transformed viewport coordinates of the rectangle are:
A ( 1 , 1 ) → A ′ ( 1/3 , − 1/6 ) ≈ ( 0.333 , − 0.167 ) B ( 4 , 1 ) → B ′ ( 5/6 , − 1/6 ) ≈ ( 0.833 , − 0.167 ) C ( 4 , 4 ) → C ′ ( 5/6 , 1/3 ) ≈ ( 0.833 , 0.333 ) D ( 1 , 4 ) → D ′ ( 1/3 , 1/3 ) ≈ ( 0.333 , 0.333 ) All past exam questions for Computer Graphics and Visualization
Padhaiko: a study app for BE Computer, Tribhuvan University. Works offline in the app.