Atelier Scribing pour le groupe Business Analysis de l'ADIRA
Clipping Scribing
-
Upload
naresh-mehra -
Category
Documents
-
view
232 -
download
0
Transcript of Clipping Scribing
-
8/2/2019 Clipping Scribing
1/23
SUBMISSION BY:- NARESH MEHRA (09010129)
SHYAM SUNDER SINGH (09010149)
10/4/2012
CLIPPING LECTURE SCRIBING |
INDIAN
INSTITUTEOF
TECHNOLOGYCOMPUTERGRAPHICS
-
8/2/2019 Clipping Scribing
2/23
Note:- This pdf contain class notes By Pinaki mitra sir
ON CLIPPING followed by examples of Clipping
2-DIMENSIONAL VIEWING
WORLD CO-ODINATE SYSTEM:Any convenient co-ordinate system
WINDOW: A world co-ordinate area selected for clipping is called window.VIEW PORT: An area on the display to which the window is mapped.
-
8/2/2019 Clipping Scribing
3/23
Window -to- viewport-coordinate transformation:
-
8/2/2019 Clipping Scribing
4/23
We want
(Xv - Xv min) / (Xv max - Xv min) = (Xw Xwmin) / (Xw max Xw min)
(Yv - Yv min) / (Yv max - Yv min) = (Yw Ywmin) / (Yw max Yw min)
Xv = Xv min + (Xw Xw min) . Sx
Yv = Yv min + (Yw Yw min) . Sy
Sx = (Xv max - Xv min) / (Xw max Xw min)
Sy = (Yv max - Yv min) / (Yw max Yw min)
1)We perform the following sequence of operations:Perform a scaling transformation using a fixed point position (Xw min, Yw
min) that scales the window area to the size of viewport.
2) Translate the scaled windows area to the position of the viewport.
Clipping operation
Point clipping
Line clipping
Polygon clipping/area clipping
-
8/2/2019 Clipping Scribing
5/23
Point clipping:
Xw min X Xw max
Yw min Y Yw max
We retain a point P(X,Y) satisfying the above property for display.
line Clipping:
Cohen-sutherland line Clipping:-
Region code:
-
8/2/2019 Clipping Scribing
6/23
X X X X
Bit-4 Bit-3 Bit-2 Bit-1
Above below right left
Bit-1 : is the sign bit of : X- Xw min
Bit-2 : is the sign bit of : Xw max - X
Bit-3 : is the sign bit of : Y -Yw min
Bit-4 : is the sign bit of :Yw max -Y
If the some bit positions of two end points have 1, then this line is reflected
because both are outside the clipping window and in the same region outside
the window.
we perform the logical AND of the region
codes corresponding to P1 and P2. if the result0000.
if the region codes of both P1 & P2 = 0000.
(Trivial acceptance)
-
8/2/2019 Clipping Scribing
7/23
INTERSECTION COMPUTATION:Line segment where P1 =(X1,Y1) & P2=(X2,Y2)
Vertical boundary:
Y = Y1+M(X- X1)
Where X = Xw min or X = Xw max
M = Y2- Y1/ X2 - X1
Horizontal boundary:
X = X1 + (Y - Y1 /M)
Where Y =Yw min or Y =Yw max
CYRUS-BECK & LIANG-BARSKY LINE CLIPPING:Parametric representation of the line for the line .
P(t) = P0 +( P1 P0).t
-
8/2/2019 Clipping Scribing
8/23
Vector : P(t)- PEi
For t =0
P(0) PEi = P0 - PEi
P(1) PEi = P1 - PEi
So Ni . (P(t) PEi ) = 0
Ni . [P0+( P1 P0).t - PEi ] = 0
Ni . [P0 - PEi ] + Ni [P1 P0].t = 0
t = Ni . [P0 - PEi ]/ Ni .[P0 P1].
T can be computed if
1)Ni 2)D 3)Ni: D (h h f d || o )
(0 or multiple intersection)
Dd h do h (.)
So h o
-
8/2/2019 Clipping Scribing
9/23
If moving from P0 to P1 , causes us to cross a particular edge to enter the
edges inside half plane, the intersection is PE(potentially entering), If it causes
to leave the edges inside half plane it is PL(potentially leaving)
Ni. D < 0 => PE (angle >90)
Ni . D > 0 => PL (angle T1 discard the entire segment, otherwise (TE.. TL) determines the
clipped portion of the line segment.
Nicholl-lee Nicholl Line Clipping (only 2-D)
-
8/2/2019 Clipping Scribing
10/23
Line
Case 1:
L,T,R,B possible position for P2.
Case2:
-
8/2/2019 Clipping Scribing
11/23
if P2 lies h o with left & top clipping window
boundaries.
Case3:
-
8/2/2019 Clipping Scribing
12/23
OR
Case 4:P2 lies in region LT if
So 1TR So 12 < So 1TL
-
8/2/2019 Clipping Scribing
13/23
(YT - Y1)/ (XR - X1) < (Y2 -Y1)/ ( X2 - X1) < (YT - Y1)/ (XL - X1)
Trivially if
(YT - Y1) ( X2 - X1) < (XL - X1).(Y2 -Y1)
From parametric equation:
X = X1 + ( X2 - X1) .u
Y = Y1 + ( Y2 - Y1) .u
x- Intersection position on the left window boundary is x=xL with u= (xL-x1/
x2-x1) & y intersection position is
Y = Y1 + ( Y2 - Y1)/ ( X2 - X1) . (XL - X1)
And intersection position with the top boundary with y=yT and u= (xT - y1/ y2-
y1) with
X = X1 + ( X2 - X1)/ ( Y2 - Y1) . (YT - Y1)
POLYGON CLIPPING:
Using line clipping applied to polygonal boundary we obtain a series of
unconnected line segments. We want the output of polygon clipper of be a
sequence of vertices that defines the clipped polygon boundaries.
-
8/2/2019 Clipping Scribing
14/23
SUTHERLAND-HODGEMAN POLYGON CLIPPING:4 possible cases when processing vertices in sequence along the polygonal
boundary:
Out in inin inout
outout
Save v1 ,2 save v2 Save v1 S
none
V1
V
V1
V2
V2
V1
V2
V1
V1 V1
2
3
-
8/2/2019 Clipping Scribing
15/23
{ , 3 } , {, 3 , 4 } , { , 3 , 4 , 5 }, { ,3 ,4 , 5 , 5}
IN SUTHERLAND-HODGEMAN algorithm, there is only one output vertex list ,
the lost vertex is always joined with the 1st vertex.
WEILER ATHERTON POLYGON CLIPPING:For clockwise processing of polygon vertices we use the following:
2
1
56
5
V2
V1
V3
V3
V2
-
8/2/2019 Clipping Scribing
16/23
For an outside-to-inside pair of vertices follow polygonal boundary.
For an inside-to-outside pair of vertices follow the window boundary in a
clockwise direction.
{ v2,2 , v3 , v4 } { 5,5 , v6 }
Examples:-Q1:- Find Region code for given line and clip by Sutherland cohen Algorithm ?
Ans:- According to Sutherland cohen Algorithm
Coordinate of point will be 0101 As it belongs to Left-Below region.
And point B will be 1010 As it lies in Right-Above region.
-
8/2/2019 Clipping Scribing
17/23
:-
Logical AND of A & B is 0000 and none of both is 0000
So it will be partially visible.
As point A & C will be 0001 i.e. nonzero so we can remove it from line segment
and now we have only BC as line segment.
Again B & C = 0000 thats why it also will be partially visible.
By 0-bit = 1 in C we can say that it has left crossed the window. So we remove
CD(left) part from
Line.
Now line segment is BD.
Similarly we can also remove BE and FE segment of line as every point hascoordinate in which
1-bit = 1. I.e. it has crossed the right part of clipping window that why will be
invisible.
And finally we get a Line DF where D & F = 0000 with both are equal to 0000.
-
8/2/2019 Clipping Scribing
18/23
So we can say that Line segment DF will be completely visible as we dont have
any bit equal to
1.
Example 2 :-
Clip below Polygon according to Sutherland-Hodgman algorithm ??
Ans:-
According to Sutherland-Hodgman algorithm we know that
1. Out -> In case:- For V1 -> V2 where V1 is the intersection point, then
we save V1, V2 (I.)
2 .In -> Out case:- For V1 -> V2 where V1 is the intersection point, then
we save V1.
3 .In -> In case :- we save V2.
-
8/2/2019 Clipping Scribing
19/23
4 .Out -> Out case:- We save nothing.
And then we clip by Left -> Top -> Right -> Below.
In given below example
As Line segments from V6 Intersects Window at two points and we get to
points by L1 and L2 from
Case (1) and case 2 respectively.
-When we clip form Left
we get new Vertex list as V2 -> V3 -> V4 -> V5 -> L1 -> L1 -> V1 .
Vertex set after Top Clip :- T2
-> V3
-> V4
-> V5
-> L1
-> L1
-> T1
Vertex set after Right Clip :- R1 -> R2 -> V4 -> V5 -> L1 -> L2 -> T1 -> T2 .
Vertex set after Below Clip :- -> R2 -> B1 -> B2 -> V4 -> V5 -> L1 -> L2 -> T1 -> T2 -
> R1
-
8/2/2019 Clipping Scribing
20/23
And thus we get a New clipped Polygon as below .
-
8/2/2019 Clipping Scribing
21/23
Example 3 :- Weiler-Atherton Algorithm
Find Clipped Polygon for Given Non-convex Polygon and clipping window??
Ans:-
Rules:-
For an outside to inside pair of vertices follow polygonal boundary.
For an inside to Outside pair of vertices follow the window boundary in a
clockwise direction.
In given Below Polygon and window as 0-1 is inside to outside thats why we
include window boundary in Clockwise direction and we get clipped part o-i-j-9.
From 8-9 and 3-4 I.e. outside to inside pair of vertices we get polygonal boundary.
Similarly by Inside to outside clipping of 5-6 We get 5-k-j-4 part.
And we get new Clipped Polygon.
-
8/2/2019 Clipping Scribing
22/23
-
8/2/2019 Clipping Scribing
23/23
Example 4: - POINT CLIPPING
Prove that given point will not be visible after clipping???
Ans:-
By condition of Point clipping we know that a point will be inside a clipping
window
If Xmin < = X