- 2073 Chaitra · 8 marks
Triangle window to viewport mapping
Short answer
After scaling and translating the triangle from window (10,10)-(40,50) to viewport (0,0)-(20,20), the transformed vertices are A'(3.33,5), B'(6.67,10), C'(13.33,5).
A triangle A (15, 20), B (20, 30) and C (30, 20) lies inside a window (10, 10), (40, 50). Find the final image of this triangle after transforming into the viewport (0, 0), (20, 20). Show all transformation steps.
Given: window (xwmin, ywmin) = (10,10), (xwmax, ywmax) = (40,50); viewport (xvmin, yvmin) = (0,0), (xvmax, yvmax) = (20,20). Triangle A(15,20), B(20,30), C(30,20) is inside the window.
Step 1: scale factors
sx = (xvmax − xvmin)/(xwmax − xwmin) = 20/30 = 0.6667
sy = (yvmax − yvmin)/(ywmax − ywmin) = 20/40 = 0.5
Step 2: transformation steps
- Translate the window's lower left corner to the origin: T(−10, −10)
- Scale by (sx, sy) = (2/3, 1/2) about the origin.
- Translate to the viewport's lower left corner: T(0, 0) (no change here).
M = T(xvmin,yvmin) · S(sx,sy) · T(−xwmin,−ywmin)
| 1 0 0 | | 2/3 0 0 | | 1 0 −10 | | 2/3 0 −20/3 |
= | 0 1 0 | · | 0 1/2 0 | · | 0 1 −10 | = | 0 1/2 −5 |
| 0 0 1 | | 0 0 1 | | 0 0 1 | | 0 0 1 |
Step 3: apply to the vertices
xv = (x − 10)·(2/3), yv = (y − 10)·(1/2)
| Point | After translation | After scaling | Viewport (final) |
|---|---|---|---|
| A (15,20) | (5, 10) | (3.33, 5) | (3.33, 5) |
| B (20,30) | (10, 20) | (6.67, 10) | (6.67, 10) |
| C (30,20) | (20, 10) | (13.33, 5) | (13.33, 5) |
Answer: the image in the viewport is the triangle A'(3.33, 5), B'(6.67, 10), C'(13.33, 5).
✓ Answer checked by Claude Opus 5.5 (high effort)
Related questions
- Rectangle window to viewport mapping · Computer Graphics, chapter 3
- 3D window to viewport transformation · Computer Graphics, chapter 4
- Cohen-Sutherland: window (10,10)-(40,40) · Computer Graphics, chapter 3
- 3D rotation about axis (1,2,3)-(10,20,30) · Computer Graphics, chapter 4
- Define window and viewport · Computer Graphics, chapter 3 · asked 2×
- Bresenham: line (10,20) to (15,2) · Computer Graphics, chapter 2 · asked 4×
- AVL tree for 10 20 30 50 45 40 8 5 3 · Data Structure and Algorithm, chapter 6
- AVL tree for 10, 20, 30, 35, 50, ... · Data Structure and Algorithm, chapter 6
- Elliptic: 2x2 grid 10/20/40/50 · Numerical Method, chapter 7 · asked 5×
- Image by two lenses 30 cm and 40 cm · Engineering Physics, chapter 5 · asked 3×