100% found this document useful (1 vote)
4K views5 pages

Liang Barsky Line Clipping Algorithm Example

The Liang Barsky line clipping algorithm is demonstrated by clipping a line defined by points P(10,30) and Q(80,90) against a window defined by A(20,20), B(90,20), C(90,70), D(20,70). The algorithm calculates values for u1 and u2 that define the line segments inside the window as I'(20, 38.57) and I''(56.67, 70). Polygon clipping is more complex than line clipping as it must maintain correct inside/outside classification and handle variable vertex counts and screen corners. Sutherland-Hodgman area clipping works by comparing the polygon to each boundary in turn to clip the

Uploaded by

Hardik Agrawal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
4K views5 pages

Liang Barsky Line Clipping Algorithm Example

The Liang Barsky line clipping algorithm is demonstrated by clipping a line defined by points P(10,30) and Q(80,90) against a window defined by A(20,20), B(90,20), C(90,70), D(20,70). The algorithm calculates values for u1 and u2 that define the line segments inside the window as I'(20, 38.57) and I''(56.67, 70). Polygon clipping is more complex than line clipping as it must maintain correct inside/outside classification and handle variable vertex counts and screen corners. Sutherland-Hodgman area clipping works by comparing the polygon to each boundary in turn to clip the

Uploaded by

Hardik Agrawal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Liang Barsky Line Clipping Algorithm Example

Window Coordinates: A(20,20), B(90,20), C(90,70), D(20,70)


Line coordinates: P(10,30), Q(80,90)

Xwmin=20 X1=10 P1=-Δx=-70 q1=x1-xwmin=10-20=-10


Δx= 80-10=70 q2=xwmax-x1=90-10=80
Ywmin=20 Y1=30 P2=Δx=70
Δy=90-30=60 q3=y1-ywmin=30-20=10
Xwmax=90 X2=80 P3=-Δy=-60
Ywmax=70 Y2=90 P4=Δy=60 q4=ywmax-y1=70-30=40

If pk=0, Line parallel


If pk<0, Line outside If pk>0, Line outside I’=> x’=x1+u1Δx
Calculate u2 value =10+(10/70)70 =20
Calculate u1 value
y’=y1+u1Δy
Pk<0:= p1, p3 Pk>0:= p2, p4 =30+(10/70)60 =38.57
u1= max(0,rk) : rk=qk/pk u2= min(1,rk) : rk=qk/pk
= max(0,q1/p1,q3/p3) = min(1,q2/p2,q4/p4) I’’=> x’’=x1+u2Δx
=max(0, -10/-70, -10/60) =min(1, 80/70, 40/60) =10+(40/60)70 =56.67
=10/70 =40/60 y’’=y1+u2Δy
=30+(40/60)60 =70

I’(20, 38.57) I’’(56.67, 70)


2D Clipping
1. Introduction
2. Point Clipping
3. Line Clipping
4. Polygon / Area Clipping
5. Text Clipping
6. Curve Clipping
Polygon Clipping

• Note the difference between clipping lines and


polygons:

January 10, 2022 Computer Graphics 4


Polygon Clipping

• Some difficulties:
• Maintaining correct inside/outside
• Variable number of vertices
• Handle screen corners
correctly

January 10, 2022 Computer Graphics 5


Sutherland-Hodgman Area Clipping
• A technique for clipping areas Sutherland
developed by Sutherland & turns up
Hodgman again. This
time with
• Put simply the polygon is clipped Gary Hodgman with
by comparing it against each whom he worked at
boundary in turn the first ever graphics
company Evans &
Sutherland

Original Area Clip Left Clip Right Clip Top Clip Bottom

January 10, 2022 Computer Graphics 6

You might also like