Module 4: 2D Viewing and clipping
Que:Define Window , Viewport and Clipping.
•Window: World
coordinate area selected for display is called window. Mostly rectangular shape
window considered.
•Viewport: An area from display device where area from window mapped.
In general we can say window means “what to see” and Viewport means “where to see”
•Clipping: Finding inside or outside region using algorithm or with any procedure with respect to window is called clipping.
•Viewport: An area from display device where area from window mapped.
In general we can say window means “what to see” and Viewport means “where to see”
•Clipping: Finding inside or outside region using algorithm or with any procedure with respect to window is called clipping.
Que:Derive Composite matrix for Window to Viewport Transformation.
Que:Explain Point Clipping and use of Point Clipping.
•Point
with coordinate (x,y) can be clipped against the window with coordinates Xwmin, Ywmin,Xwmax,Ywmax using
following inequalities:
Xwmin ≤ x ≤ Xwmax
Ywmin ≤ x ≤ Ywmax
•Point will be accepted if it satisfies both inequalities.
Que:Explain Cohen-Sutherland line clipping Algorithm.
Cohen Sutherland Line Clipping Algorithm
•It is
oldest and most popular algorithm.
Step1)
Accept line end points A(x1,y1) ,B(x2,y2) and window coordinates Xwmin,Ywmin,Xwmax,Ywmax as
input.
Step2)
Calculate Region codes for line endpoints i.e. B4B3B2B1. Let
for (X,Y)point
B1=Sign(Xwmin-X) :Left
B2=Sign(X-Xwmax) :Right
B3=Sign(Ywmin-Y) :Bottom
B4=Sign(Y-Ywmax) :Top
such that Sign A=1 if A>0 Sign A=0 if A<0
Step3)
- If region codes for both endpoint are 0000 then line is
totally inside
accept and stop.
- If
AND of
region codes is non
zero value then line is totally
outside, Discard the line and stop.
- If AND of region codes is Zero, then line is clipping
candidate.
Step4)
Determine which boundary is intersecting based on 1 in region code.
B1=1 then x’=Xwmin :Left
B2=1
then x’=Xwmax :Right
B3=1
then y’=Ywmin :Bottom
B4=1 then y’=Ywmax :Top
B4=1 then y’=Ywmax :Top
Step5) Determine
intersecting coordinates (x’,y’)using following equations.
when
y’=Ywmin or y’=Ywmax x'=x1+1/m(y'-y1)
when
x’=Xwmin or
x’=Xwmax y'=y1+m(x'-x1)
Step
6) Go to step (2)