This lecture discusses different clipping algorithms. Clipping removes portions of primitives like points, lines, and polygons that lie outside a region of interest. It describes algorithms for point clipping, line clipping including the Cohen-Sutherland algorithm, and polygon clipping using the Sutherland-Hodgman algorithm. The Sutherland-Hodgman algorithm clips polygons by processing each polygon edge against window edges and handling four different cases that may result.
Clipping is used in the Computer Graphics sector and My presentation Will Help you to Enrich your idea's on Clipping. Utilize my Presentation as a Reference...
Clipping is used in the Computer Graphics sector and My presentation Will Help you to Enrich your idea's on Clipping. Utilize my Presentation as a Reference...
Identify those parts of a scene that are visible from a chosen viewing position.
Visible-surface detection algorithms are broadly classified according to whether
they deal with object definitions directly or with their projected images.
These two approaches are called object-space methods and image-space methods, respectively
An object-space method compares
objects and parts of objects to each other within the scene definition to determine which surfaces, as a whole, we should label as visible.
In an image-space algorithm, visibility is decided point by point at each pixel position on the projection plane.
Cohen-Sutherland Line Clipping Algorithm:
When drawing a 2D line on screen, it might happen that one or both of the endpoints are outside the screen while a part of the line should still be visible. In that case, an efficient algorithm is needed to find two new endpoints that are on the edges on the screen, so that the part of the line that's visible can now be drawn. This way, all those points of the line outside the screen are clipped away and you don't need to waste any execution time on them.
A good clipping algorithm is the Cohen-Sutherland algorithm for this solution.
By,
Maruf Abdullah Rion
Do Not just learn computer graphics an close your computer tab and go away..
APPLY them in real business,
Visit Daroko blog for real IT skills applications,androind, Computer graphics,Networking,Programming,IT jobs Types, IT news and applications,blogging,Builing a website, IT companies and how you can form yours, Technology news and very many More IT related subject.
-simply google:Daroko blog(professionalbloggertricks.com)
• Daroko blog (www.professionalbloggertricks.com)
• Presentation by Daroko blog, to see More tutorials more than this one here, Daroko blog has all tutorials related with IT course, simply visit the site by simply Entering the phrase Daroko blog (www.professionalbloggertricks.com) to search engines such as Google or yahoo!, learn some Blogging, affiliate marketing ,and ways of making Money with the computer graphic Applications(it is useless to learn all these tutorials when you can apply them as a student you know),also learn where you can apply all IT skills in a real Business Environment after learning Graphics another computer realate courses.ly
• Be practically real, not just academic reader
Presentation By daroko blog-where IT learners apply Skills in real business environment.
-------------------------------------------------------------------------------------
This presentation will introduce you to color representation in computer graphics.
-----------------------------------------------------------------
Do Not just learn computer graphics an close your computer tab and go away..
APPLY them in real business,
Visit Daroko blog for real IT skills applications,androind, Computer graphics,Networking,Programming,IT jobs Types, IT news and applications,blogging,Builing a website, IT companies and how you can form yours, Technology news and very many More IT related subject.
-simply google:Daroko blog(professionalbloggertricks.com)
-------------------------------------------------------------------
• Daroko blog (www.professionalbloggertricks.com)
• Presentation by Daroko blog, to see More tutorials more than this one here, Daroko blog has all tutorials related with IT course, simply visit the site by simply Entering the phrase Daroko blog (www.professionalbloggertricks.com) to search engines such as Google or yahoo!, learn some Blogging, affiliate marketing ,and ways of making Money with the computer graphic Applications(it is useless to learn all these tutorials when you can apply them as a student you know),also learn where you can apply all IT skills in a real Business Environment after learning Graphics another computer realate courses.ly
• Be practically real, not just academic reader
Identify those parts of a scene that are visible from a chosen viewing position.
Visible-surface detection algorithms are broadly classified according to whether
they deal with object definitions directly or with their projected images.
These two approaches are called object-space methods and image-space methods, respectively
An object-space method compares
objects and parts of objects to each other within the scene definition to determine which surfaces, as a whole, we should label as visible.
In an image-space algorithm, visibility is decided point by point at each pixel position on the projection plane.
Cohen-Sutherland Line Clipping Algorithm:
When drawing a 2D line on screen, it might happen that one or both of the endpoints are outside the screen while a part of the line should still be visible. In that case, an efficient algorithm is needed to find two new endpoints that are on the edges on the screen, so that the part of the line that's visible can now be drawn. This way, all those points of the line outside the screen are clipped away and you don't need to waste any execution time on them.
A good clipping algorithm is the Cohen-Sutherland algorithm for this solution.
By,
Maruf Abdullah Rion
Do Not just learn computer graphics an close your computer tab and go away..
APPLY them in real business,
Visit Daroko blog for real IT skills applications,androind, Computer graphics,Networking,Programming,IT jobs Types, IT news and applications,blogging,Builing a website, IT companies and how you can form yours, Technology news and very many More IT related subject.
-simply google:Daroko blog(professionalbloggertricks.com)
• Daroko blog (www.professionalbloggertricks.com)
• Presentation by Daroko blog, to see More tutorials more than this one here, Daroko blog has all tutorials related with IT course, simply visit the site by simply Entering the phrase Daroko blog (www.professionalbloggertricks.com) to search engines such as Google or yahoo!, learn some Blogging, affiliate marketing ,and ways of making Money with the computer graphic Applications(it is useless to learn all these tutorials when you can apply them as a student you know),also learn where you can apply all IT skills in a real Business Environment after learning Graphics another computer realate courses.ly
• Be practically real, not just academic reader
Presentation By daroko blog-where IT learners apply Skills in real business environment.
-------------------------------------------------------------------------------------
This presentation will introduce you to color representation in computer graphics.
-----------------------------------------------------------------
Do Not just learn computer graphics an close your computer tab and go away..
APPLY them in real business,
Visit Daroko blog for real IT skills applications,androind, Computer graphics,Networking,Programming,IT jobs Types, IT news and applications,blogging,Builing a website, IT companies and how you can form yours, Technology news and very many More IT related subject.
-simply google:Daroko blog(professionalbloggertricks.com)
-------------------------------------------------------------------
• Daroko blog (www.professionalbloggertricks.com)
• Presentation by Daroko blog, to see More tutorials more than this one here, Daroko blog has all tutorials related with IT course, simply visit the site by simply Entering the phrase Daroko blog (www.professionalbloggertricks.com) to search engines such as Google or yahoo!, learn some Blogging, affiliate marketing ,and ways of making Money with the computer graphic Applications(it is useless to learn all these tutorials when you can apply them as a student you know),also learn where you can apply all IT skills in a real Business Environment after learning Graphics another computer realate courses.ly
• Be practically real, not just academic reader
Do Not just learn computer graphics an close your computer tab and go away..
APPLY them in real business,
Visit Daroko blog for real IT skills applications,androind, Computer graphics,Networking,Programming,IT jobs Types, IT news and applications,blogging,Builing a website, IT companies and how you can form yours, Technology news and very many More IT related subject.
-simply google:Daroko blog(professionalbloggertricks.com)
• Daroko blog (www.professionalbloggertricks.com)
• Presentation by Daroko blog, to see More tutorials more than this one here, Daroko blog has all tutorials related with IT course, simply visit the site by simply Entering the phrase Daroko blog (www.professionalbloggertricks.com) to search engines such as Google or yahoo!, learn some Blogging, affiliate marketing ,and ways of making Money with the computer graphic Applications(it is useless to learn all these tutorials when you can apply them as a student you know),also learn where you can apply all IT skills in a real Business Environment after learning Graphics another computer realate courses.ly
• Be practically real, not just academic reader
Java programming presentations By Daroko blog
Do not just read java as a programmer, find projects and start making some Money, at DAROKO BLOG,WE Guide you through what you have learned in the classroom to a real business Environment, find java applications to a real business Environment, find also all IT Solutions and How you can apply them, find the best companies where you can get the IT jobs worldwide, Find java contract, Complete and start making some cash, find clients within your Country, refer and get paid when you complete the work.
Not Just a contact, at daroko Blog (www.professionalbloggertricks.com/),you are also being taught how you can apply all IT related field in real world.
Simply Google, Daroko Blog or visit (www.professionalbloggertricks.com/) to Know More about all these service now.
Do not just learn and go, apply them in real world.
Do Not just learn computer graphics an close your computer tab and go away..
APPLY them in real business,
Visit Daroko blog for real IT skills applications,androind, Computer graphics,Networking,Programming,IT jobs Types, IT news and applications,blogging,Builing a website, IT companies and how you can form yours, Technology news and very many More IT related subject.
-simply google:Daroko blog(professionalbloggertricks.com)
• Daroko blog (www.professionalbloggertricks.com)
• Presentation by Daroko blog, to see More tutorials more than this one here, Daroko blog has all tutorials related with IT course, simply visit the site by simply Entering the phrase Daroko blog (www.professionalbloggertricks.com) to search engines such as Google or yahoo!, learn some Blogging, affiliate marketing ,and ways of making Money with the computer graphic Applications(it is useless to learn all these tutorials when you can apply them as a student you know),also learn where you can apply all IT skills in a real Business Environment after learning Graphics another computer realate courses.ly
• Be practically real, not just academic reader
This presentation will introduce you to Raster details in computer graphics.
---------------------------------------------------------------------------
Do Not just learn computer graphics an close your computer tab and go away..
APPLY them in real business,
Visit Daroko blog for real IT skills applications,androind, Computer graphics,Networking,Programming,IT jobs Types, IT news and applications,blogging,Builing a website, IT companies and how you can form yours, Technology news and very many More IT related subject.
-simply google:Daroko blog(professionalbloggertricks.com)
• Daroko blog (www.professionalbloggertricks.com)
• Presentation by Daroko blog, to see More tutorials more than this one here, Daroko blog has all tutorials related with IT course, simply visit the site by simply Entering the phrase Daroko blog (www.professionalbloggertricks.com) to search engines such as Google or yahoo!, learn some Blogging, affiliate marketing ,and ways of making Money with the computer graphic Applications(it is useless to learn all these tutorials when you can apply them as a student you know),also learn where you can apply all IT skills in a real Business Environment after learning Graphics another computer realate courses.ly
• Be practically real, not just academic reader
Java programming presentations By Daroko blog
Do not just read java as a programmer, find projects and start making some Money, at DAROKO BLOG,WE Guide you through what you have learned in the classroom to a real business Environment, find java applications to a real business Environment, find also all IT Solutions and How you can apply them, find the best companies where you can get the IT jobs worldwide, Find java contract, Complete and start making some cash, find clients within your Country, refer and get paid when you complete the work.
Not Just a contact, at daroko Blog(www.professionalbloggertricks.com/),you are also being taught How you can apply all IT related field in real world.
Simply Google, Daroko Blog or visit (www.professionalbloggertricks.com/) to Know More about all these service now.
Do not just learn and god, Apply them in real world
Do Not just learn computer graphics an close your computer tab and go away..
APPLY them in real business,
Visit Daroko blog for real IT skills applications,androind, Computer graphics,Networking,Programming,IT jobs Types, IT news and applications,blogging,Builing a website, IT companies and how you can form yours, Technology news and very many More IT related subject.
-simply google:Daroko blog(professionalbloggertricks.com)
• Daroko blog (www.professionalbloggertricks.com)
• Presentation by Daroko blog, to see More tutorials more than this one here, Daroko blog has all tutorials related with IT course, simply visit the site by simply Entering the phrase Daroko blog (www.professionalbloggertricks.com) to search engines such as Google or yahoo!, learn some Blogging, affiliate marketing ,and ways of making Money with the computer graphic Applications(it is useless to learn all these tutorials when you can apply them as a student you know),also learn where you can apply all IT skills in a real Business Environment after learning Graphics another computer realate courses.ly
• Be practically real, not just academic reader
presentation By Daroko blog-where IT learners Apply skills.
This topic an presentation will introduce you to Computer graphics hardware types.
---------------------------------
• Daroko blog (www.professionalbloggertricks.com)
• Presentation by Daroko blog, to see More tutorials more than this one here, Daroko blog has all tutorials related with IT course, simply visit the site by simply Entering the phrase Daroko blog (www.professionalbloggertricks.com) to search engines such as Google or yahoo!, learn some Blogging, affiliate marketing ,and ways of making Money with the computer graphic Applications(it is useless to learn all these tutorials when you can apply them as a student you know),also learn where you can apply all IT skills in a real Business Environment after learning Graphics another computer realate courses.ly
• Be practically real, not just academic reader
Do Not just learn computer graphics an close your computer tab and go away..
APPLY them in real business,
Visit Daroko blog for real IT skills applications,androind, Computer graphics,Networking,Programming,IT jobs Types, IT news and applications,blogging,Builing a website, IT companies and how you can form yours, Technology news and very many More IT related subject.
-simply google:Daroko blog(professionalbloggertricks.com)
Do Not just learn computer graphics an close your computer tab and go away..
APPLY them in real business,
Visit Daroko blog for real IT skills applications,androind, Computer graphics,Networking,Programming,IT jobs Types, IT news and applications,blogging,Builing a website, IT companies and how you can form yours, Technology news and very many More IT related subject.
-simply google:Daroko blog(professionalbloggertricks.com)
• Daroko blog (www.professionalbloggertricks.com)
• Presentation by Daroko blog, to see More tutorials more than this one here, Daroko blog has all tutorials related with IT course, simply visit the site by simply Entering the phrase Daroko blog (www.professionalbloggertricks.com) to search engines such as Google or yahoo!, learn some Blogging, affiliate marketing ,and ways of making Money with the computer graphic Applications(it is useless to learn all these tutorials when you can apply them as a student you know),also learn where you can apply all IT skills in a real Business Environment after learning Graphics another computer realate courses.ly
• Be practically real, not just academic reader
• Daroko blog (www.professionalbloggertricks.com)
• Presentation by Daroko blog, to see More tutorials more than this one here, Daroko blog has all tutorials related with IT course, simply visit the site by simply Entering the phrase Daroko blog (www.professionalbloggertricks.com) to search engines such as Google or yahoo!, learn some Blogging, affiliate marketing ,and ways of making Money with the computer graphic Applications(it is useless to learn all these tutorials when you can apply them as a student you know),also learn where you can apply all IT skills in a real Business Environment after learning Graphics another computer realate courses.ly
• Be practically real, not just academic reader
The Lian-Barsky algorithm is a line clipping algorithm. This algorithm is more efficient than Cohen–Sutherland line clipping algorithm and can be extended to 3-Dimensional clipping. This algorithm is considered to be the faster parametric line-clipping algorithm. The following concepts are used in this clipping:
The parametric equation of the line.
The inequalities describing the range of the clipping window which is used to determine the intersections between the line and the clip window.
he capability that show some part of object internal a specify window is called windowing and a rectangular region in a world coordinate system is called window. ... Points and lines which are outside the window are "cut off" from view. This process of "cutting off" parts of the image of the world is called Clipping.
For More Business ideas, business management, Business plan, small business startup, website development, ways of making money online, u how you start your own Blog and make money, find contract an get paid instantly ,find writing work, find clients within your country and get paid for it.
Simply visit Daroko Blog (www.professionalbloggertricks.com)
Google the statement: Daroko Blog
Java programming presentations By Daroko blog
Do not just read java as a programmer, find projects and start making some Money, at DAROKO BLOG,WE Guide you through what you have learned in the classroom to a real business Environment, find java applications to a real business Environment, find also all IT Solutions and How you can apply them, find the best companies where you can get the IT jobs worldwide, Find java contract, Complete and start making some cash, find clients within your Country, refer and get paid when you complete the work.
Not Just a contact, at daroko Blog (www.professionalbloggertricks.com/),you are also being taught how you can apply all IT related field in real world.
Simply Google, Daroko Blog or visit (www.professionalbloggertricks.com/) to Know More about all these service now.
Do not just learn and go, apply them in real world.
Java programming presentations By Daroko blog
Do not just read java as a programmer, find projects and start making some Money, at DAROKO BLOG,WE Guide you through what you have learned in the classroom to a real business Environment, find java applications to a real business Environment, find also all IT Solutions and How you can apply them, find the best companies where you can get the IT jobs worldwide, Find java contract, Complete and start making some cash, find clients within your Country, refer and get paid when you complete the work.
Not Just a contact, at daroko Blog (www.professionalbloggertricks.com/),you are also being taught how you can apply all IT related field in real world.
Simply Google, Daroko Blog or visit (www.professionalbloggertricks.com/) to Know More about all these service now.
Do not just learn and go, apply them in real world.
Java programming presentations By Daroko blog
Do not just read java as a programmer, find projects and start making some Money, at DAROKO BLOG,WE Guide you through what you have learned in the classroom to a real business Environment, find java applications to a real business Environment, find also all IT Solutions and How you can apply them, find the best companies where you can get the IT jobs worldwide, Find java contract, Complete and start making some cash, find clients within your Country, refer and get paid when you complete the work.
Not Just a contact, at daroko Blog (www.professionalbloggertricks.com/),you are also being taught how you can apply all IT related field in real world.
Simply Google, Daroko Blog or visit (www.professionalbloggertricks.com/) to Know More about all these service now.
Do not just learn and go, apply them in real world.
Java programming presentations By Daroko blog
Do not just read java as a programmer, find projects and start making some Money, at DAROKO BLOG,WE Guide you through what you have learned in the classroom to a real business Environment, find java applications to a real business Environment, find also all IT Solutions and How you can apply them, find the best companies where you can get the IT jobs worldwide, Find java contract, Complete and start making some cash, find clients within your Country, refer and get paid when you complete the work.
Not Just a contact, at daroko Blog (www.professionalbloggertricks.com/),you are also being taught how you can apply all IT related field in real world.
Simply Google, Daroko Blog or visit (www.professionalbloggertricks.com/) to Know More about all these service now.
Do not just learn and go, apply them in real world.
Java programming presentations By Daroko blog
Do not just read java as a programmer, find projects and start making some Money, at DAROKO BLOG,WE Guide you through what you have learned in the classroom to a real business Environment, find java applications to a real business Environment, find also all IT Solutions and How you can apply them, find the best companies where you can get the IT jobs worldwide, Find java contract, Complete and start making some cash, find clients within your Country, refer and get paid when you complete the work.
Not Just a contact, at daroko Blog(www.professionalbloggertricks.com/),you are also being taught How you can apply all IT related field in real world.
Simply Google, Daroko Blog or visit (www.professionalbloggertricks.com/) to Know More about all these service now.
Do not just learn and god, Apply them in real world
Do Not just learn computer graphics an close your computer tab and go away..
APPLY them in real business,
Visit Daroko blog for real IT skills applications,androind, Computer graphics,Networking,Programming,IT jobs Types, IT news and applications,blogging,Builing a website, IT companies and how you can form yours, Technology news and very many More IT related subject.
-simply google:Daroko blog(professionalbloggertricks.com)
• Daroko blog (www.professionalbloggertricks.com)
• Presentation by Daroko blog, to see More tutorials more than this one here, Daroko blog has all tutorials related with IT course, simply visit the site by simply Entering the phrase Daroko blog (www.professionalbloggertricks.com) to search engines such as Google or yahoo!, learn some Blogging, affiliate marketing ,and ways of making Money with the computer graphic Applications(it is useless to learn all these tutorials when you can apply them as a student you know),also learn where you can apply all IT skills in a real Business Environment after learning Graphics another computer realate courses.ly
• Be practically real, not just academic reader
Do Not just learn computer graphics an close your computer tab and go away..
APPLY them in real business,
Visit Daroko blog for real IT skills applications,androind, Computer graphics,Networking,Programming,IT jobs Types, IT news and applications,blogging,Builing a website, IT companies and how you can form yours, Technology news and very many More IT related subject.
-simply google:Daroko blog(professionalbloggertricks.com)
• Daroko blog (www.professionalbloggertricks.com)
• Presentation by Daroko blog, to see More tutorials more than this one here, Daroko blog has all tutorials related with IT course, simply visit the site by simply Entering the phrase Daroko blog (www.professionalbloggertricks.com) to search engines such as Google or yahoo!, learn some Blogging, affiliate marketing ,and ways of making Money with the computer graphic Applications(it is useless to learn all these tutorials when you can apply them as a student you know),also learn where you can apply all IT skills in a real Business Environment after learning Graphics another computer realate courses.ly
• Be practically real, not just academic reader
This is an introduction to 2D and 3 in computer graphics presented by daroko blog.
• Daroko blog (www.professionalbloggertricks.com)
• Presentation by Daroko blog, to see More tutorials more than this one here, Daroko blog has all tutorials related with IT course, simply visit the site by simply Entering the phrase Daroko blog (www.professionalbloggertricks.com) to search engines such as Google or yahoo!, learn some Blogging, affiliate marketing ,and ways of making Money with the computer graphic Applications(it is useless to learn all these tutorials when you can apply them as a student you know),also learn where you can apply all IT skills in a real Business Environment after learning Graphics another computer relate courses.ly
• Be practically real, not just academic reader
Daroko blog:
An introduction to computer graphics
• Daroko blog (www.professionalbloggertricks.com)
• Presentation by Daroko blog, to see More tutorials more than this one here, Daroko blog has all tutorials related with IT course, simply visit the site by simply Entering the phrase Daroko blog (www.professionalbloggertricks.com) to search engines such as Google or yahoo!, learn some Blogging, affiliate marketing ,and ways of making Money with the computer graphic Applications(it is useless to learn all these tutorials when you can apply them as a student you know),also learn where you can apply all IT skills in a real Business Environment after learning Graphics another computer realate courses.ly
• Be practically real, not just academic reader
This notes is powered by Daroko Blog(www.professionalbloggertricks.com) ..these notes are not allowed to be produce in anywhere else,if you need more notes ,kindly go to daroko blog:
If you want to read more about Interaction in human computer interaction you can simply go to Daroko blog,simply Google Daroko blog on your Browsers.Daroko blog has everything starting from technology news,blogging tips,wordpress tips and information technology tutorials,simply Go to Daroko blog and read everything in technology
This is the introductory features to human computer interface,powered by Daroko blog,this is the Only slide that will teach the interaction device in human computer interaction.
If you want to read more about Interaction in human computer interaction you can simply go to Daroko blog,simply Google Daroko blog on your Browsers.Daroko blog has everything starting from technology news,blogging tips,wordpress tips and information technology tutorials,simply Go to Daroko blog and read everything in technology.
This Document by Daroko blog,this describe the human computer interface in use today,to read More about Notes on human computer intrface,kindly go to daroko blog,this is ust a section of those notes,go to daroko blog and read all the Notes,check on the tutorials part on that blog and then choose human computer interafec
More from Daroko blog(www.professionalbloggertricks.com) (14)
3. Clipping
We have talked about 2D scan conversion of
line-segments and polygons
What if endpoints of line segments or vertices
of polygons lie outside the visible device
region?
Need clipping!
Clipping .pdf notes
4. Clipping
Clipping: Remove points outside a region of interest – clip
window.
Want to discard everything that’s outside of our window...
Primitives: point, line-segment, and polygon.
Point clipping: Remove points outside window.
A point is either entirely inside the region or not.
Line-segment clipping: Remove portion of line segment outside
window.
Line segments can straddle the region boundary.
Polygon clipping: Remove portion of polygon outside window
5. Review: Parametric
representation of line
or equivalently
A and B are non-coincident endpoints.
For , L(t) defines an infinite line.
For , L(t) defines a line segment from A to B.
Good for generating points on a line.
Not so good for testing if a given point is on a line.
A
B
6. Review: Implicit line Equation
representation of line:
•P is a point on the line.
• is a vector perpendicular to the line.
• gives us the signed distance from any point Q to the line.
•The sign of tells us if Q is on the left or right of the line, relative to the
direction of .
•If is zero, then Q is on the line.
•Use same form for the implicit representation of a half space.
7. Clipping a point to a half space
Represent window edges implicitly.
Use the implicit form of a line to classify a point Q.
Must choose a convention for the normal:
points to the inside.
Check the sign of :
If > 0, then Q is inside.
Otherwise clip (discard) Q: It is on the edge or outside.
8. Clipping a line segment to a
half space
There are three cases:
The line segment is entirely inside: Keep it.
The line segment is entirely outside: Discard it.
The line segment is partially inside and partially outside:
Generate new line to represent part inside.
10. Do the easy stuff first
Do the easy stuff first:
We can devise easy (and fast!) tests for the first two cases:
AND Outside
AND Inside
Need to decide whether “on the boundary” is inside or
outside?
Trivial tests are important in computer graphics:
Particularly if the trivial case is the most common one.
Particularly if we can reuse the computation for the non-
trivial case
11. Do the hard stuff only if we
have to
If line segment partially inside and partially outside, need to clip it:
•Line segment from A to B in parametric form:
•When t=0, L(t)=A. When t=1, L(t)=B.
•We now have the following:
12. Find the Intersection
•We want t such that :
•Solving for t gives us
•NOTE:
The values we use for our simple test can be reused to compute t:
13. Clipping a line segment to a
window
Just clip to each of four half spaces in turn.
given: line segment (A, B), clip in-place:
for each edge (P,n)
wecA = (A-P) . n
wecB = (B-P) . n
if ( wecA < 0 AND wecB < 0 ) then reject
if ( wecA > 0 AND wecB > 0 ) then next
t = wecA / (wecA - wecB)
if ( wecA < 0 ) then
A = A + t*(B-A)
else
B = A + t*(B-A)
endif
endfor
Note:
This Algorithm can clip lines to any convex window.
Optimizations can be made for the special case of horizontal and vertical
window edges
14. Optimization (Cohen-
Sutherland)
Q: Solving for the intersection point is expensive.
Can we avoid evaluation of a clip on one edge if we
know the line segment is out on another?
A: Yes.
Do all trivial tests first.
Combine results using Boolean operations to determine
Trivial accept on window: all edges have trivial accept
Trivial reject on window: any edge has trivial reject
Do full clip only if no trivial accept/reject on window
16. Cohen-Sutherland Algorithm
Computing the outcodes for a point is trivial
Just use comparison
Trivial rejection is performed using the logical
and of the two endpoints
A line segment is rejected if the result of and
operation > 0. Why?
18. Using Outcodes
CD: outcode (C) = 0, outcode(D) ≠ 0
Compute intersection
Location of 1 in outcode(D) determines which
edge to intersect with
Note if there were a segment from A to a point in
a region with 2 ones in outcode, we might have to
do two interesections
19. Using Outcodes
EF: outcode(E) logically ANDed with
outcode(F) (bitwise) ≠ 0
Both outcodes have a 1 bit in the same place
Line segment is outside of corresponding side of
clipping window
reject
20. Using Outcodes
GH and IJ: same outcodes, neither zero but
logical AND yields zero
Shorten line segment by intersecting with one
of sides of window
Compute outcode of intersection (new
endpoint of shortened line segment)
Re-execute algorithm
21. Cohen-Sutherland Algorithm
Now we can efficiently reject lines completely
to the left, right, top, or bottom of the
rectangle.
If the line cannot be trivially rejected (what
cases?), the line is split in half at a clip line.
Not that about one half of the line can be
rejected trivially
This method is efficient for large or small
windows.
22. Cohen-Sutherland Algorithm
clip (int Ax, int Ay, int Bx, int By)
{
int cA = code(Ax, Ay);
int cB = code(Bx, By);
while (cA | cB) { // not completely inside the window
if(cA & cB) return; // rejected
if(cA) {
update Ax, Ay to the clip line depending
on which outer region the point is in
cA = code(Ax, Ay);
} else {
update Bx, By to the clip line depending
on which outer region the point is in
cB = code(Bx, By);
}
}
drawLine(Ax, Ay, Bx, By);
}
23. 3D Line-clip Algorithm
• Half-space now lies on one side of a plane.
• Implicit formula for plane in 3D is same as that for line in 2D.
• Parametric formula for line to be clipped is unchanged.
– Use 6-bit outcodes
– When needed, clip line segment against planes
24. Polygon Clipping
Not as simple as line segment clipping
Clipping a line segment yields at most one line
segment
Clipping a polygon can yield multiple polygons
However, clipping a convex polygon can yield
at most one other polygon
25. Tessellation and Convexity
One strategy is to replace nonconvex (concave)
polygons with a set of triangular polygons (a
tessellation)
Also makes fill easier
Tessellation code in GLU library
27. Polygon Clipping (Sutherland-Hodgman):
Window must be a convex polygon
Polygon to be clipped can be convex or not
Approach:
Polygon to be clipped is given as a sequence of vertices
Each polygon edge is a pair
Don't forget wrap around; is also an edge
Process all polygon edges in succession against a window edge
Polygon in - polygon out
Repeat on resulting polygon with next sequential window edge
Sutherland-Hodgman algorithm deals with concave polygons efficiently
Built upon efficient line segment clipping
Sutherland-Hodgman Polygon
Clipping Algorithm
28. Four Cases
There are four cases to consider
Some notations:
s = vj is the polygon edge starting vertex
p = vj+1 is the polygon edge ending vertex
i is a polygon-edge/window-edge intersection point
wj is the next polygon vertex to be output
29. Case 1
Polygon edge is entirely inside the window edge
•p is next vertex of resulting polygon
30. Case 2
Polygon edge crosses window edge going out
• Intersection point i is next vertex of resulting polygon
•
35. Summary of Clipping
Point Clipping
Simple: in or out
Line Clipping:
Based on point clipping
Compute the line segment inside the window
Need to compute intersections between the line segment and window edges.
Consider trivial cases first to reduce computation.
outcodes algorithm
Polygon Clipping:
More complex. A convex polygon may be clipped into multiple polygons.
Based on line clipping
Clip the polygon against window edges in a sequence