Perform window to viewport transformation for the point Assume that
Perform window to viewport transformation for the point (20, 15), Assume that (Xwmin, Ywmin) is (0,0); (Xwmax, Ywmax) is (100,100);
(Xvmin, Yvmin) is (5,5); (Xvmax, YVmax) is (20,20).
The value of x and y in the viewport is
- A.
x = 4, y = 4
- B.
x = 3, y = 3
- C.
x = 8, y = 7.25
- D.
x = 3, y = 4
Attempted by 33 students.
Show answer & explanation
Correct answer: C
(Xwmin, Ywmin) and (Xwmax, Ywmax) = window boundaries
(Xvmin, Yvmin) and (Xvmax, Yvmax) = viewport boundaries
(xw, yw) = point in window coordinates
(xv, yv) = point in viewport coordinates
Then:xv=Xvmin+((xw-Xwmin)/(Xwmax-Xwmin))⋅(Xvmax-Xvmin)
yv=Yvmin+((yw-Ywmin)/(Ywmax-Ywmin))⋅(Yvmax-Yvmin)
Given:
Point in window: (xw, yw) = (20, 15)
Window: (Xwmin, Ywmin) = (0, 0) and (Xwmax, Ywmax) = (100, 100)
Viewport: (Xvmin, Yvmin) = (5, 5) and (Xvmax, Yvmax) = (20, 20)
Apply the formula:
For xv:xv=5+((20-0)/(100-0))⋅(20-5)
xv=5+(20/100)⋅15=5+0.2⋅15=5+3=▭8
For yv:
yv=5+((15-0)/(100-0))⋅(20-5)
yv=5+(15/100)⋅15=5+0.15⋅15=5+2.25=▭7.25