- 2081 Chaitra (new course) · 4 marks
Rectangle window to viewport mapping
Short answer
The viewing transformation matrix has sx=sy=1/6, translation (0.1667,-0.3333). The rectangle points map to A'(0.333,-0.167), B'(0.833,-0.167), C'(0.833,0.333), D'(0.333,0.333); only the portion inside the window maps to viewport region (0.5,0)-(0.833,0.333).
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.
Given: window: xwmin = 2, ywmin = 2, xwmax = 5, ywmax = 5. Viewport: xvmin = 0.5, yvmin = 0, xvmax = 1, yvmax = 0.5. The rectangle is A(1,1), B(4,1), C(4,4), D(1,4).
Scale factors
sx = (1 − 0.5)/(5 − 2) = 0.5/3 = 1/6 = 0.1667
sy = (0.5 − 0)/(5 − 2) = 0.5/3 = 1/6 = 0.1667
Viewing transformation matrix
M = T(xvmin, yvmin) · S(sx, sy) · T(−xwmin, −ywmin)
| 1 0 0.5 | | 1/6 0 0 | | 1 0 −2 | | 1/6 0 0.1667 |
= | 0 1 0 | · | 0 1/6 0 | · | 0 1 −2 | = | 0 1/6 −0.3333 |
| 0 0 1 | | 0 0 1 | | 0 0 1 | | 0 0 1 |
(0.5 − 2/6 = 0.1667 and 0 − 2/6 = −0.3333.)
Mapped points
xv = 0.5 + (x − 2)/6, yv = (y − 2)/6
| Point | (xv, yv) |
|---|---|
| A (1,1) | (0.333, −0.167) |
| B (4,1) | (0.833, −0.167) |
| C (4,4) | (0.833, 0.333) |
| D (1,4) | (0.333, 0.333) |
Answer: the transformed points are A'(0.333, −0.167), B'(0.833, −0.167), C'(0.833, 0.333), D'(0.333, 0.333). The parts of the rectangle with x < 2 or y < 2 lie outside the window, so after clipping only the portion x from 2 to 4, y from 2 to 4 is displayed, mapped to the viewport region (0.5, 0) to (0.833, 0.333).
✓ Answer checked by Claude Opus 5.5 (high effort)
Related questions
- Triangle window to viewport mapping · Computer Graphics, chapter 3
- 3D window to viewport transformation · Computer Graphics, chapter 4
- 2D viewing pipeline with matrices · Computer Graphics, chapter 3 · asked 5×
- Define window and viewport · Computer Graphics, chapter 3 · asked 2×
- Halve rectangle ABCD about its centre · Computer Graphics, chapter 3
- 3D world to viewing coordinate matrix · Computer Graphics, chapter 4 · asked 2×
- Thiessen average rainfall, four gauges at rectangle corners · Engineering Hydrology, chapter 2