Q 1. Given a horizontal line of pixels, numbered from f (first) to / (last), tha
ID: 3744270 • Letter: Q
Question
Q 1. Given a horizontal line of pixels, numbered from f (first) to / (last), that has to be mapped to a segment of the X-axis from startx to endx. Derive a formula that will map any pixel to a point on the X- axis. Q 2. Given a vertical line of pixels, numbered from t (top) to b(bottom), that has to be mapped to a segment of the Y-axis from starty to endy. Derive a formula that will map any point on this segment of the Y-axis to the appropriate pixel. Note that t maps to endy and b maps to startyExplanation / Answer
Answer :
1) f(first) has to be mapped with startx and l(last) with endx.
Let us denote the pixels with numbers 1,2,3,...N
Where f(first) = (1)
And l(last) = (N)
So general formula for nth pixel lying between 1 to N is :
(n)th pixel = startx + (n-1) on x axis
2) similarly taking b(bottom ) as 1 and top as N here, to map the N pixels on y axis the general formula is:
nth pixel = starty + (n-1)
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.