Clipping - empslocal.ex.ac.ukempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides06.pdf · User...
Transcript of Clipping - empslocal.ex.ac.ukempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides06.pdf · User...
ECM2410: Graphics and Animation
Clipping
Clipping 1/16
Rendering and clipping
To render a sceneDetermine objects to be rendered.Transform objects to device space.Clip to:
Device boundaries.Viewport boundaries.User specified clipping path.
Draw in framebuffer.
Clipping to:
Avoid drawing outside device.User special effects, e.g.,
Scene outside a window
Clip to near and far viewing planes in 3D.
Rendering and Clipping Clipping 2/16
Rendering and clipping
To render a sceneDetermine objects to be rendered.Transform objects to device space.Clip to:
Device boundaries.Viewport boundaries.User specified clipping path.
Draw in framebuffer.
Clipping to:
Avoid drawing outside device.User special effects, e.g.,
Scene outside a window
Clip to near and far viewing planes in 3D.
Rendering and Clipping Clipping 2/16
Rendering and clipping
To render a sceneDetermine objects to be rendered.Transform objects to device space.Clip to:
Device boundaries.Viewport boundaries.User specified clipping path.
Draw in framebuffer.
Clipping to:
Avoid drawing outside device.User special effects, e.g.,
Scene outside a window
Clip to near and far viewing planes in 3D.
Rendering and Clipping Clipping 2/16
Rendering and clipping
To render a sceneDetermine objects to be rendered.Transform objects to device space.Clip to:
Device boundaries.Viewport boundaries.User specified clipping path.
Draw in framebuffer.
Clipping to:
Avoid drawing outside device.User special effects, e.g.,
Scene outside a window
Clip to near and far viewing planes in 3D.
Rendering and Clipping Clipping 2/16
Rendering and clipping
To render a sceneDetermine objects to be rendered.Transform objects to device space.Clip to:
Device boundaries.Viewport boundaries.User specified clipping path.
Draw in framebuffer.
Clipping to:
Avoid drawing outside device.User special effects, e.g.,
Scene outside a window
Clip to near and far viewing planes in 3D.
Rendering and Clipping Clipping 2/16
Rendering and clipping
To render a sceneDetermine objects to be rendered.Transform objects to device space.Clip to:
Device boundaries.Viewport boundaries.User specified clipping path.
Draw in framebuffer.
Clipping to:
Avoid drawing outside device.User special effects, e.g.,
Scene outside a window
Clip to near and far viewing planes in 3D.
Rendering and Clipping Clipping 2/16
Rendering and clipping
To render a sceneDetermine objects to be rendered.Transform objects to device space.Clip to:
Device boundaries.Viewport boundaries.User specified clipping path.
Draw in framebuffer.
Clipping to:
Avoid drawing outside device.User special effects, e.g.,
Scene outside a window
Clip to near and far viewing planes in 3D.
Rendering and Clipping Clipping 2/16
Rendering and clipping
To render a sceneDetermine objects to be rendered.Transform objects to device space.Clip to:
Device boundaries.Viewport boundaries.User specified clipping path.
Draw in framebuffer.
Clipping to:
Avoid drawing outside device.User special effects, e.g.,
Scene outside a window
Clip to near and far viewing planes in 3D.
Rendering and Clipping Clipping 2/16
Rendering and clipping
To render a sceneDetermine objects to be rendered.Transform objects to device space.Clip to:
Device boundaries.Viewport boundaries.User specified clipping path.
Draw in framebuffer.
Clipping to:
Avoid drawing outside device.User special effects, e.g.,
Scene outside a window
Clip to near and far viewing planes in 3D.
Rendering and Clipping Clipping 2/16
Rendering and clipping
To render a sceneDetermine objects to be rendered.Transform objects to device space.Clip to:
Device boundaries.Viewport boundaries.User specified clipping path.
Draw in framebuffer.
Clipping to:
Avoid drawing outside device.User special effects, e.g.,
Scene outside a window
Clip to near and far viewing planes in 3D.
Rendering and Clipping Clipping 2/16
Rendering and clipping
To render a sceneDetermine objects to be rendered.Transform objects to device space.Clip to:
Device boundaries.Viewport boundaries.User specified clipping path.
Draw in framebuffer.
Clipping to:
Avoid drawing outside device.User special effects, e.g.,
Scene outside a window
Clip to near and far viewing planes in 3D.
Rendering and Clipping Clipping 2/16
Rendering and clipping
To render a sceneDetermine objects to be rendered.Transform objects to device space.Clip to:
Device boundaries.Viewport boundaries.User specified clipping path.
Draw in framebuffer.
Clipping to:
Avoid drawing outside device.User special effects, e.g.,
Scene outside a window
Clip to near and far viewing planes in 3D.
Rendering and Clipping Clipping 2/16
Rendering and clipping
To render a sceneDetermine objects to be rendered.Transform objects to device space.Clip to:
Device boundaries.Viewport boundaries.User specified clipping path.
Draw in framebuffer.
Clipping to:
Avoid drawing outside device.User special effects, e.g.,
Scene outside a window
Clip to near and far viewing planes in 3D.
Rendering and Clipping Clipping 2/16
Rendering and clipping
To render a sceneDetermine objects to be rendered.Transform objects to device space.Clip to:
Device boundaries.Viewport boundaries.User specified clipping path.
Draw in framebuffer.
Clipping to:
Avoid drawing outside device.User special effects, e.g.,
Scene outside a window
Clip to near and far viewing planes in 3D.
Rendering and Clipping Clipping 2/16
Clipping
Line segments and otherprimitives may be specifiedoutside the viewport or devicespace.
Want to confine geometry to aclipping region.
Clipping region is commonly aconvex polygon
Clipping rectangle is mostfrequent case:
xmin ≤x ≤ xmax
ymin ≤y ≤ ymax
Clipping Clipping 3/16
Clipping
Line segments and otherprimitives may be specifiedoutside the viewport or devicespace.
Want to confine geometry to aclipping region.
Clipping region is commonly aconvex polygon
Clipping rectangle is mostfrequent case:
xmin ≤x ≤ xmax
ymin ≤y ≤ ymax
Clipping Clipping 3/16
Clipping
Line segments and otherprimitives may be specifiedoutside the viewport or devicespace.
Want to confine geometry to aclipping region.
Clipping region is commonly aconvex polygon
Clipping rectangle is mostfrequent case:
xmin ≤x ≤ xmax
ymin ≤y ≤ ymax
Clipping Clipping 3/16
Clipping
Line segments and otherprimitives may be specifiedoutside the viewport or devicespace.
Want to confine geometry to aclipping region.
Clipping region is commonly aconvex polygon
Clipping rectangle is mostfrequent case:
xmin ≤x ≤ xmax
ymin ≤y ≤ ymax
Clipping Clipping 3/16
Clipping
Line segments and otherprimitives may be specifiedoutside the viewport or devicespace.
Want to confine geometry to aclipping region.
Clipping region is commonly aconvex polygon
Clipping rectangle is mostfrequent case:
xmin ≤x ≤ xmax
ymin ≤y ≤ ymax
Clipping Clipping 3/16
Clipping
Line segments and otherprimitives may be specifiedoutside the viewport or devicespace.
Want to confine geometry to aclipping region.
Clipping region is commonly aconvex polygon
Clipping rectangle is mostfrequent case:
xmin ≤x ≤ xmax
ymin ≤y ≤ ymax
Clipping Clipping 3/16
Clipping Methods
Scan convert to an off-screen bitmap;copy clipped bitmap to framebuffer.Permits arbitrarily shaped clipping regions.
Scissor
Clip on the fly during scan conversion.Doesn’t require an extra bitmap and can be fast.
Analytic clipping
Calculate parts of the primitives that lie in the clip region.Simple and efficient for points and line segments.
Clipping / Methods Clipping 4/16
Clipping Methods
Scan convert to an off-screen bitmap;copy clipped bitmap to framebuffer.Permits arbitrarily shaped clipping regions.
Scissor
Clip on the fly during scan conversion.Doesn’t require an extra bitmap and can be fast.
Analytic clipping
Calculate parts of the primitives that lie in the clip region.Simple and efficient for points and line segments.
Clipping / Methods Clipping 4/16
Clipping Methods
Scan convert to an off-screen bitmap;copy clipped bitmap to framebuffer.Permits arbitrarily shaped clipping regions.
Scissor
Clip on the fly during scan conversion.Doesn’t require an extra bitmap and can be fast.
Analytic clipping
Calculate parts of the primitives that lie in the clip region.Simple and efficient for points and line segments.
Clipping / Methods Clipping 4/16
Clipping Methods
Scan convert to an off-screen bitmap;copy clipped bitmap to framebuffer.Permits arbitrarily shaped clipping regions.
Scissor
Clip on the fly during scan conversion.Doesn’t require an extra bitmap and can be fast.
Analytic clipping
Calculate parts of the primitives that lie in the clip region.Simple and efficient for points and line segments.
Clipping / Methods Clipping 4/16
Clipping Methods
Scan convert to an off-screen bitmap;copy clipped bitmap to framebuffer.Permits arbitrarily shaped clipping regions.
Scissor
Clip on the fly during scan conversion.Doesn’t require an extra bitmap and can be fast.
Analytic clipping
Calculate parts of the primitives that lie in the clip region.Simple and efficient for points and line segments.
Clipping / Methods Clipping 4/16
Clipping Methods
Scan convert to an off-screen bitmap;copy clipped bitmap to framebuffer.Permits arbitrarily shaped clipping regions.
Scissor
Clip on the fly during scan conversion.Doesn’t require an extra bitmap and can be fast.
Analytic clipping
Calculate parts of the primitives that lie in the clip region.Simple and efficient for points and line segments.
Clipping / Methods Clipping 4/16
Clipping Methods
Scan convert to an off-screen bitmap;copy clipped bitmap to framebuffer.Permits arbitrarily shaped clipping regions.
Scissor
Clip on the fly during scan conversion.Doesn’t require an extra bitmap and can be fast.
Analytic clipping
Calculate parts of the primitives that lie in the clip region.Simple and efficient for points and line segments.
Clipping / Methods Clipping 4/16
Clipping Methods
Scan convert to an off-screen bitmap;copy clipped bitmap to framebuffer.Permits arbitrarily shaped clipping regions.
Scissor
Clip on the fly during scan conversion.Doesn’t require an extra bitmap and can be fast.
Analytic clipping
Calculate parts of the primitives that lie in the clip region.Simple and efficient for points and line segments.
Clipping / Methods Clipping 4/16
Clipping Methods
Scan convert to an off-screen bitmap;copy clipped bitmap to framebuffer.Permits arbitrarily shaped clipping regions.
Scissor
Clip on the fly during scan conversion.Doesn’t require an extra bitmap and can be fast.
Analytic clipping
Calculate parts of the primitives that lie in the clip region.Simple and efficient for points and line segments.
Clipping / Methods Clipping 4/16
Clipping Methods
Scan convert to an off-screen bitmap;copy clipped bitmap to framebuffer.Permits arbitrarily shaped clipping regions.
Scissor
Clip on the fly during scan conversion.Doesn’t require an extra bitmap and can be fast.
Analytic clipping
Calculate parts of the primitives that lie in the clip region.Simple and efficient for points and line segments.
Clipping / Methods Clipping 4/16
Clipping to Arbitrary Regions
Offscreen FramebufferOffscreen
Render clipping region to offscreen bitmap.
Render scene to offscreen bitmap.
Transfer pointwise intersection to visible framebuffer.
Clipping / Arbitrary Regions Clipping 5/16
Clipping to Arbitrary Regions
Offscreen FramebufferOffscreen
Render clipping region to offscreen bitmap.
Render scene to offscreen bitmap.
Transfer pointwise intersection to visible framebuffer.
Clipping / Arbitrary Regions Clipping 5/16
Clipping to Arbitrary Regions
Offscreen FramebufferOffscreen
Render clipping region to offscreen bitmap.
Render scene to offscreen bitmap.
Transfer pointwise intersection to visible framebuffer.
Clipping / Arbitrary Regions Clipping 5/16
Clipping to Arbitrary Regions
Offscreen FramebufferOffscreen
Render clipping region to offscreen bitmap.
Render scene to offscreen bitmap.
Transfer pointwise intersection to visible framebuffer.
Clipping / Arbitrary Regions Clipping 5/16
Clipping to Arbitrary Regions
Offscreen FramebufferOffscreen
Render clipping region to offscreen bitmap.
Render scene to offscreen bitmap.
Transfer pointwise intersection to visible framebuffer.
Clipping / Arbitrary Regions Clipping 5/16
Point Clipping
Keep point if it is inside the clipping region.Keep point if it satisfies:
xmin ≤ x ≤ xmax
ymin ≤ y ≤ ymax
Question:How to generalise to
Arbitrary Convex Polygons?Arbitrary Concave Polygons?
Answer:
See Hearn & Baker, Foley et al.
Point Clipping Clipping 6/16
Point Clipping
Keep point if it is inside the clipping region.Keep point if it satisfies:
xmin ≤ x ≤ xmax
ymin ≤ y ≤ ymax
Question:How to generalise to
Arbitrary Convex Polygons?Arbitrary Concave Polygons?
Answer:
See Hearn & Baker, Foley et al.
Point Clipping Clipping 6/16
Point Clipping
Keep point if it is inside the clipping region.Keep point if it satisfies:
xmin ≤ x ≤ xmax
ymin ≤ y ≤ ymax
Question:How to generalise to
Arbitrary Convex Polygons?Arbitrary Concave Polygons?
Answer:
See Hearn & Baker, Foley et al.
Point Clipping Clipping 6/16
Point Clipping
Keep point if it is inside the clipping region.Keep point if it satisfies:
xmin ≤ x ≤ xmax
ymin ≤ y ≤ ymax
Question:How to generalise to
Arbitrary Convex Polygons?Arbitrary Concave Polygons?
Answer:
See Hearn & Baker, Foley et al.
Point Clipping Clipping 6/16
Point Clipping
Keep point if it is inside the clipping region.Keep point if it satisfies:
xmin ≤ x ≤ xmax
ymin ≤ y ≤ ymax
Question:How to generalise to
Arbitrary Convex Polygons?Arbitrary Concave Polygons?
Answer:
See Hearn & Baker, Foley et al.
Point Clipping Clipping 6/16
Point Clipping
Keep point if it is inside the clipping region.Keep point if it satisfies:
xmin ≤ x ≤ xmax
ymin ≤ y ≤ ymax
Question:How to generalise to
Arbitrary Convex Polygons?Arbitrary Concave Polygons?
Answer:
See Hearn & Baker, Foley et al.
Point Clipping Clipping 6/16
Point Clipping
Keep point if it is inside the clipping region.Keep point if it satisfies:
xmin ≤ x ≤ xmax
ymin ≤ y ≤ ymax
Question:How to generalise to
Arbitrary Convex Polygons?Arbitrary Concave Polygons?
Answer:
See Hearn & Baker, Foley et al.
Point Clipping Clipping 6/16
Point Clipping
Keep point if it is inside the clipping region.Keep point if it satisfies:
xmin ≤ x ≤ xmax
ymin ≤ y ≤ ymax
Question:How to generalise to
Arbitrary Convex Polygons?Arbitrary Concave Polygons?
Answer:
See Hearn & Baker, Foley et al.
Point Clipping Clipping 6/16
Point Clipping
Keep point if it is inside the clipping region.Keep point if it satisfies:
xmin ≤ x ≤ xmax
ymin ≤ y ≤ ymax
Question:How to generalise to
Arbitrary Convex Polygons?Arbitrary Concave Polygons?
Answer:
See Hearn & Baker, Foley et al.
Point Clipping Clipping 6/16
Point Clipping
Keep point if it is inside the clipping region.Keep point if it satisfies:
xmin ≤ x ≤ xmax
ymin ≤ y ≤ ymax
Question:How to generalise to
Arbitrary Convex Polygons?Arbitrary Concave Polygons?
Answer:
See Hearn & Baker, Foley et al.
Point Clipping Clipping 6/16
Point Clipping
Keep point if it is inside the clipping region.Keep point if it satisfies:
xmin ≤ x ≤ xmax
ymin ≤ y ≤ ymax
Question:How to generalise to
Arbitrary Convex Polygons?Arbitrary Concave Polygons?
Answer:
See Hearn & Baker, Foley et al.
Point Clipping Clipping 6/16
Point Clipping
Keep point if it is inside the clipping region.Keep point if it satisfies:
xmin ≤ x ≤ xmax
ymin ≤ y ≤ ymax
Question:How to generalise to
Arbitrary Convex Polygons?Arbitrary Concave Polygons?
Answer:
See Hearn & Baker, Foley et al.
Point Clipping Clipping 6/16
Point Clipping
Keep point if it is inside the clipping region.Keep point if it satisfies:
xmin ≤ x ≤ xmax
ymin ≤ y ≤ ymax
Question:How to generalise to
Arbitrary Convex Polygons?Arbitrary Concave Polygons?
Answer:
See Hearn & Baker, Foley et al.
Point Clipping Clipping 6/16
Clipping line segments
Both endpoints inside clipping region.Trivial acceptance.One endpoint inside, one endpoint outside.There must be an intersection point p withedge of clip region;replace outside endpoint with p.
No endpoint insideNo intersection with clipping regionReject segment.
Intersections with 2 edges of clipping regionReplace segment with segment between the two crossingpoints
Result must be either a single segment or vacuous.
Clipping Line Segments Clipping 7/16
Clipping line segments
Both endpoints inside clipping region.Trivial acceptance.One endpoint inside, one endpoint outside.There must be an intersection point p withedge of clip region;replace outside endpoint with p.
No endpoint insideNo intersection with clipping regionReject segment.
Intersections with 2 edges of clipping regionReplace segment with segment between the two crossingpoints
Result must be either a single segment or vacuous.
Clipping Line Segments Clipping 7/16
Clipping line segments
Both endpoints inside clipping region.Trivial acceptance.One endpoint inside, one endpoint outside.There must be an intersection point p withedge of clip region;replace outside endpoint with p.
No endpoint insideNo intersection with clipping regionReject segment.
Intersections with 2 edges of clipping regionReplace segment with segment between the two crossingpoints
Result must be either a single segment or vacuous.
Clipping Line Segments Clipping 7/16
Clipping line segments
Both endpoints inside clipping region.Trivial acceptance.One endpoint inside, one endpoint outside.There must be an intersection point p withedge of clip region;replace outside endpoint with p.
No endpoint insideNo intersection with clipping regionReject segment.
Intersections with 2 edges of clipping regionReplace segment with segment between the two crossingpoints
Result must be either a single segment or vacuous.
Clipping Line Segments Clipping 7/16
Clipping line segments
Both endpoints inside clipping region.Trivial acceptance.One endpoint inside, one endpoint outside.There must be an intersection point p withedge of clip region;replace outside endpoint with p.
No endpoint insideNo intersection with clipping regionReject segment.
Intersections with 2 edges of clipping regionReplace segment with segment between the two crossingpoints
Result must be either a single segment or vacuous.
Clipping Line Segments Clipping 7/16
Clipping line segments
Both endpoints inside clipping region.Trivial acceptance.One endpoint inside, one endpoint outside.There must be an intersection point p withedge of clip region;replace outside endpoint with p.
No endpoint insideNo intersection with clipping regionReject segment.
Intersections with 2 edges of clipping regionReplace segment with segment between the two crossingpoints
Result must be either a single segment or vacuous.
Clipping Line Segments Clipping 7/16
Clipping line segments
Both endpoints inside clipping region.Trivial acceptance.One endpoint inside, one endpoint outside.There must be an intersection point p withedge of clip region;replace outside endpoint with p.
No endpoint insideNo intersection with clipping regionReject segment.
Intersections with 2 edges of clipping regionReplace segment with segment between the two crossingpoints
Result must be either a single segment or vacuous.
Clipping Line Segments Clipping 7/16
Clipping line segments
Both endpoints inside clipping region.Trivial acceptance.One endpoint inside, one endpoint outside.There must be an intersection point p withedge of clip region;replace outside endpoint with p.
No endpoint insideNo intersection with clipping regionReject segment.
Intersections with 2 edges of clipping regionReplace segment with segment between the two crossingpoints
Result must be either a single segment or vacuous.
Clipping Line Segments Clipping 7/16
Clipping line segments
Both endpoints inside clipping region.Trivial acceptance.One endpoint inside, one endpoint outside.There must be an intersection point p withedge of clip region;replace outside endpoint with p.
No endpoint insideNo intersection with clipping regionReject segment.
Intersections with 2 edges of clipping regionReplace segment with segment between the two crossingpoints
Result must be either a single segment or vacuous.
Clipping Line Segments Clipping 7/16
Clipping line segments
Both endpoints inside clipping region.Trivial acceptance.One endpoint inside, one endpoint outside.There must be an intersection point p withedge of clip region;replace outside endpoint with p.
No endpoint insideNo intersection with clipping regionReject segment.
Intersections with 2 edges of clipping regionReplace segment with segment between the two crossingpoints
Result must be either a single segment or vacuous.
Clipping Line Segments Clipping 7/16
Clipping line segments
Both endpoints inside clipping region.Trivial acceptance.One endpoint inside, one endpoint outside.There must be an intersection point p withedge of clip region;replace outside endpoint with p.
No endpoint insideNo intersection with clipping regionReject segment.
Intersections with 2 edges of clipping regionReplace segment with segment between the two crossingpoints
Result must be either a single segment or vacuous.
Clipping Line Segments Clipping 7/16
Clipping line segments
Both endpoints inside clipping region.Trivial acceptance.One endpoint inside, one endpoint outside.There must be an intersection point p withedge of clip region;replace outside endpoint with p.
No endpoint insideNo intersection with clipping regionReject segment.
Intersections with 2 edges of clipping regionReplace segment with segment between the two crossingpoints
Result must be either a single segment or vacuous.
Clipping Line Segments Clipping 7/16
Clipping line segments
Both endpoints inside clipping region.Trivial acceptance.One endpoint inside, one endpoint outside.There must be an intersection point p withedge of clip region;replace outside endpoint with p.
No endpoint insideNo intersection with clipping regionReject segment.
Intersections with 2 edges of clipping regionReplace segment with segment between the two crossingpoints
Result must be either a single segment or vacuous.
Clipping Line Segments Clipping 7/16
Calculating Intersections
Parametric representation of line segments
x = x1 + t(x2 − x1)
y = y1 + t(y2 − y1)
To find intersection with ymin, put y = ymin:
t∗ =ymin − y1
y2 − y1
(x1, y1)
(x2, y2)
ymin
If 0 ≤ t∗ ≤ 1 then the line segment intersects ymin at t∗
Thus x coordinate of intersection is x = x1 + t∗(x2 − x1)
Otherwise the line segment does not intersect ymin
Clipping Line Segments / Intersections Clipping 8/16
Calculating Intersections
Parametric representation of line segments
x = x1 + t(x2 − x1)
y = y1 + t(y2 − y1)
To find intersection with ymin, put y = ymin:
t∗ =ymin − y1
y2 − y1
(x1, y1)
(x2, y2)
ymin
If 0 ≤ t∗ ≤ 1 then the line segment intersects ymin at t∗
Thus x coordinate of intersection is x = x1 + t∗(x2 − x1)
Otherwise the line segment does not intersect ymin
Clipping Line Segments / Intersections Clipping 8/16
Calculating Intersections
Parametric representation of line segments
x = x1 + t(x2 − x1)
y = y1 + t(y2 − y1)
To find intersection with ymin, put y = ymin:
t∗ =ymin − y1
y2 − y1 (x1, y1)
(x2, y2)
ymin
If 0 ≤ t∗ ≤ 1 then the line segment intersects ymin at t∗
Thus x coordinate of intersection is x = x1 + t∗(x2 − x1)
Otherwise the line segment does not intersect ymin
Clipping Line Segments / Intersections Clipping 8/16
Calculating Intersections
Parametric representation of line segments
x = x1 + t(x2 − x1)
y = y1 + t(y2 − y1)
To find intersection with ymin, put y = ymin:
t∗ =ymin − y1
y2 − y1 (x1, y1)
(x2, y2)
ymin
If 0 ≤ t∗ ≤ 1 then the line segment intersects ymin at t∗
Thus x coordinate of intersection is x = x1 + t∗(x2 − x1)
Otherwise the line segment does not intersect ymin
Clipping Line Segments / Intersections Clipping 8/16
Calculating Intersections
Parametric representation of line segments
x = x1 + t(x2 − x1)
y = y1 + t(y2 − y1)
To find intersection with ymin, put y = ymin:
t∗ =ymin − y1
y2 − y1 (x1, y1)
(x2, y2)
ymin
If 0 ≤ t∗ ≤ 1 then the line segment intersects ymin at t∗
Thus x coordinate of intersection is x = x1 + t∗(x2 − x1)
Otherwise the line segment does not intersect ymin
Clipping Line Segments / Intersections Clipping 8/16
Calculating Intersections
Parametric representation of line segments
x = x1 + t(x2 − x1)
y = y1 + t(y2 − y1)
To find intersection with ymin, put y = ymin:
t∗ =ymin − y1
y2 − y1 (x1, y1)
(x2, y2)
ymin
If 0 ≤ t∗ ≤ 1 then the line segment intersects ymin at t∗
Thus x coordinate of intersection is x = x1 + t∗(x2 − x1)
Otherwise the line segment does not intersect ymin
Clipping Line Segments / Intersections Clipping 8/16
Calculating Intersections
Parametric representation of line segments
x = x1 + t(x2 − x1)
y = y1 + t(y2 − y1)
To find intersection with ymin, put y = ymin:
t∗ =ymin − y1
y2 − y1 (x1, y1)
(x2, y2)
ymin
If 0 ≤ t∗ ≤ 1 then the line segment intersects ymin at t∗
Thus x coordinate of intersection is x = x1 + t∗(x2 − x1)
Otherwise the line segment does not intersect ymin
Clipping Line Segments / Intersections Clipping 8/16
Calculating Intersections
Parametric representation of line segments
x = x1 + t(x2 − x1)
y = y1 + t(y2 − y1)
To find intersection with ymin, put y = ymin:
t∗ =ymin − y1
y2 − y1 (x1, y1)
(x2, y2)
ymin
If 0 ≤ t∗ ≤ 1 then the line segment intersects ymin at t∗
Thus x coordinate of intersection is x = x1 + t∗(x2 − x1)
Otherwise the line segment does not intersect ymin
Clipping Line Segments / Intersections Clipping 8/16
Calculating Intersections
Parametric representation of line segments
x = x1 + t(x2 − x1)
y = y1 + t(y2 − y1)
To find intersection with ymin, put y = ymin:
t∗ =ymin − y1
y2 − y1 (x1, y1)
(x2, y2)
ymin
If 0 ≤ t∗ ≤ 1 then the line segment intersects ymin at t∗
Thus x coordinate of intersection is x = x1 + t∗(x2 − x1)
Otherwise the line segment does not intersect ymin
Clipping Line Segments / Intersections Clipping 8/16
Calculating Intersections
Parametric representation of line segments
x = x1 + t(x2 − x1)
y = y1 + t(y2 − y1)
To find intersection with ymin, put y = ymin:
t∗ =ymin − y1
y2 − y1 (x1, y1)
(x2, y2)
ymin
If 0 ≤ t∗ ≤ 1 then the line segment intersects ymin at t∗
Thus x coordinate of intersection is x = x1 + t∗(x2 − x1)
Otherwise the line segment does not intersect ymin
Clipping Line Segments / Intersections Clipping 8/16
Brute Force Clipping
A. Classify endpoints to identifyrelevant case.4 comparisons per endpoint.
B. Compute intersection with each clip region edge to findintersection points.Intersection with each edge may have to be calculated.
Expensive – lots of redundant intersection calculations.
Brute Force Clipping Clipping 9/16
Brute Force Clipping
A. Classify endpoints to identifyrelevant case.4 comparisons per endpoint.
B. Compute intersection with each clip region edge to findintersection points.Intersection with each edge may have to be calculated.
Expensive – lots of redundant intersection calculations.
Brute Force Clipping Clipping 9/16
Brute Force Clipping
A. Classify endpoints to identifyrelevant case.4 comparisons per endpoint.
B. Compute intersection with each clip region edge to findintersection points.Intersection with each edge may have to be calculated.
Expensive – lots of redundant intersection calculations.
Brute Force Clipping Clipping 9/16
Brute Force Clipping
A. Classify endpoints to identifyrelevant case.4 comparisons per endpoint.
B. Compute intersection with each clip region edge to findintersection points.Intersection with each edge may have to be calculated.
Expensive – lots of redundant intersection calculations.
Brute Force Clipping Clipping 9/16
Brute Force Clipping
A. Classify endpoints to identifyrelevant case.4 comparisons per endpoint.
B. Compute intersection with each clip region edge to findintersection points.Intersection with each edge may have to be calculated.
Expensive – lots of redundant intersection calculations.
Brute Force Clipping Clipping 9/16
Brute Force Clipping
A. Classify endpoints to identifyrelevant case.4 comparisons per endpoint.
B. Compute intersection with each clip region edge to findintersection points.Intersection with each edge may have to be calculated.
Expensive – lots of redundant intersection calculations.
Brute Force Clipping Clipping 9/16
Brute Force Clipping
A. Classify endpoints to identifyrelevant case.4 comparisons per endpoint.
B. Compute intersection with each clip region edge to findintersection points.Intersection with each edge may have to be calculated.
Expensive – lots of redundant intersection calculations.
Brute Force Clipping Clipping 9/16
Cohen-Sutherland Algorithm
TBRL
0000
1000 1010
0010
01100100
1001
0001
0101
TBRL
TBRL
1. Classify each endpoint with respect toTop, Bottom, Right and Lefthalfplanes:
outside top: y > ymax
outside bottom: y < ymin
outside right: x > xmax
outside left: x < xmin
(Found from sign bit of the difference)
2. Assemble classifications into 4 bitoutcode for each endpoint.
3. Trivial acceptance if bitwise or ofoutcodes is zero.
4. Trivial rejection if bitwise and ofoutcodes is non-zero.
Cohen-Sutherland Algorithm Clipping 10/16
Cohen-Sutherland Algorithm
TBRL
0000
1000 1010
0010
01100100
1001
0001
0101
TBRL
TBRL
1. Classify each endpoint with respect toTop, Bottom, Right and Lefthalfplanes:
outside top: y > ymax
outside bottom: y < ymin
outside right: x > xmax
outside left: x < xmin
(Found from sign bit of the difference)
2. Assemble classifications into 4 bitoutcode for each endpoint.
3. Trivial acceptance if bitwise or ofoutcodes is zero.
4. Trivial rejection if bitwise and ofoutcodes is non-zero.
Cohen-Sutherland Algorithm Clipping 10/16
Cohen-Sutherland Algorithm
TBRL
0000
1000 1010
0010
01100100
1001
0001
0101
TBRL
TBRL
1. Classify each endpoint with respect toTop, Bottom, Right and Lefthalfplanes:
outside top: y > ymax
outside bottom: y < ymin
outside right: x > xmax
outside left: x < xmin
(Found from sign bit of the difference)
2. Assemble classifications into 4 bitoutcode for each endpoint.
3. Trivial acceptance if bitwise or ofoutcodes is zero.
4. Trivial rejection if bitwise and ofoutcodes is non-zero.
Cohen-Sutherland Algorithm Clipping 10/16
Cohen-Sutherland Algorithm
TBRL
0000
1000 1010
0010
01100100
1001
0001
0101
TBRL
TBRL
1. Classify each endpoint with respect toTop, Bottom, Right and Lefthalfplanes:
outside top: y > ymax
outside bottom: y < ymin
outside right: x > xmax
outside left: x < xmin
(Found from sign bit of the difference)
2. Assemble classifications into 4 bitoutcode for each endpoint.
3. Trivial acceptance if bitwise or ofoutcodes is zero.
4. Trivial rejection if bitwise and ofoutcodes is non-zero.
Cohen-Sutherland Algorithm Clipping 10/16
Cohen-Sutherland Algorithm
TBRL
0000
1000 1010
0010
01100100
1001
0001
0101
TBRL
TBRL
1. Classify each endpoint with respect toTop, Bottom, Right and Lefthalfplanes:
outside top: y > ymax
outside bottom: y < ymin
outside right: x > xmax
outside left: x < xmin
(Found from sign bit of the difference)
2. Assemble classifications into 4 bitoutcode for each endpoint.
3. Trivial acceptance if bitwise or ofoutcodes is zero.
4. Trivial rejection if bitwise and ofoutcodes is non-zero.
Cohen-Sutherland Algorithm Clipping 10/16
Cohen-Sutherland Algorithm
TBRL
0000
1000 1010
0010
01100100
1001
0001
0101
TBRL
TBRL
1. Classify each endpoint with respect toTop, Bottom, Right and Lefthalfplanes:
outside top: y > ymax
outside bottom: y < ymin
outside right: x > xmax
outside left: x < xmin
(Found from sign bit of the difference)
2. Assemble classifications into 4 bitoutcode for each endpoint.
3. Trivial acceptance if bitwise or ofoutcodes is zero.
4. Trivial rejection if bitwise and ofoutcodes is non-zero.
Cohen-Sutherland Algorithm Clipping 10/16
Cohen-Sutherland Algorithm
TBRL
0000
1000 1010
0010
01100100
1001
0001
0101
TBRL
TBRL
1. Classify each endpoint with respect toTop, Bottom, Right and Lefthalfplanes:
outside top: y > ymax
outside bottom: y < ymin
outside right: x > xmax
outside left: x < xmin
(Found from sign bit of the difference)
2. Assemble classifications into 4 bitoutcode for each endpoint.
3. Trivial acceptance if bitwise or ofoutcodes is zero.
4. Trivial rejection if bitwise and ofoutcodes is non-zero.
Cohen-Sutherland Algorithm Clipping 10/16
Cohen-Sutherland Algorithm
TBRL
0000
1000 1010
0010
01100100
1001
0001
0101
TBRL
TBRL
1. Classify each endpoint with respect toTop, Bottom, Right and Lefthalfplanes:
outside top: y > ymax
outside bottom: y < ymin
outside right: x > xmax
outside left: x < xmin
(Found from sign bit of the difference)
2. Assemble classifications into 4 bitoutcode for each endpoint.
3. Trivial acceptance if bitwise or ofoutcodes is zero.
4. Trivial rejection if bitwise and ofoutcodes is non-zero.
Cohen-Sutherland Algorithm Clipping 10/16
Cohen-Sutherland Algorithm
TBRL
0000
1000 1010
0010
01100100
1001
0001
0101
TBRL
TBRL
1. Classify each endpoint with respect toTop, Bottom, Right and Lefthalfplanes:
outside top: y > ymax
outside bottom: y < ymin
outside right: x > xmax
outside left: x < xmin
(Found from sign bit of the difference)
2. Assemble classifications into 4 bitoutcode for each endpoint.
3. Trivial acceptance if bitwise or ofoutcodes is zero.
4. Trivial rejection if bitwise and ofoutcodes is non-zero.
Cohen-Sutherland Algorithm Clipping 10/16
Cohen-Sutherland Algorithm
TBRL
0000
1000 1010
0010
01100100
1001
0001
0101
TBRL
TBRL
1. Classify each endpoint with respect toTop, Bottom, Right and Lefthalfplanes:
outside top: y > ymax
outside bottom: y < ymin
outside right: x > xmax
outside left: x < xmin
(Found from sign bit of the difference)
2. Assemble classifications into 4 bitoutcode for each endpoint.
3. Trivial acceptance if bitwise or ofoutcodes is zero.
4. Trivial rejection if bitwise and ofoutcodes is non-zero.
Cohen-Sutherland Algorithm Clipping 10/16
Cohen-Sutherland Algorithm
TBRL
0000
1000 1010
0010
01100100
1001
0001
0101
TBRL
TBRL
1. Classify each endpoint with respect toTop, Bottom, Right and Lefthalfplanes:
outside top: y > ymax
outside bottom: y < ymin
outside right: x > xmax
outside left: x < xmin
(Found from sign bit of the difference)
2. Assemble classifications into 4 bitoutcode for each endpoint.
3. Trivial acceptance if bitwise or ofoutcodes is zero.
4. Trivial rejection if bitwise and ofoutcodes is non-zero.
Cohen-Sutherland Algorithm Clipping 10/16
Exercise
Find the outcodes for the line segments:
Cohen-Sutherland Algorithm / Exercise Clipping 11/16
Exercise
Find the outcodes for the line segments:
Cohen-Sutherland Algorithm / Exercise Clipping 11/16
Exercise
Find the outcodes for the line segments:
Cohen-Sutherland Algorithm / Exercise Clipping 11/16
Solution: Outline
Each 1 bit in the outcode corresponds to a crossed boundary.
TBRL
0000
0000
01001
2
3
While not trivial acceptance or rejection:
Clip segment to boundaries in turn.A 1 in the outcode indicates thatend of the line should be clipped.
After each clip recompute outcodefor appropriate endpoint.
Cohen-Sutherland Algorithm / Solution Clipping 12/16
Solution: Outline
Each 1 bit in the outcode corresponds to a crossed boundary.
TBRL
0000
0000
01001
2
3
While not trivial acceptance or rejection:
Clip segment to boundaries in turn.A 1 in the outcode indicates thatend of the line should be clipped.
After each clip recompute outcodefor appropriate endpoint.
Cohen-Sutherland Algorithm / Solution Clipping 12/16
Solution: Outline
Each 1 bit in the outcode corresponds to a crossed boundary.
TBRL
0000
0000
01001
2
3
While not trivial acceptance or rejection:
Clip segment to boundaries in turn.A 1 in the outcode indicates thatend of the line should be clipped.
After each clip recompute outcodefor appropriate endpoint.
Cohen-Sutherland Algorithm / Solution Clipping 12/16
Solution: Outline
Each 1 bit in the outcode corresponds to a crossed boundary.
TBRL
0000
0000
01001
2
3
While not trivial acceptance or rejection:
Clip segment to boundaries in turn.A 1 in the outcode indicates thatend of the line should be clipped.
After each clip recompute outcodefor appropriate endpoint.
Cohen-Sutherland Algorithm / Solution Clipping 12/16
Solution: Outline
Each 1 bit in the outcode corresponds to a crossed boundary.
TBRL
0000
0000
01001
2
3
While not trivial acceptance or rejection:
Clip segment to boundaries in turn.A 1 in the outcode indicates thatend of the line should be clipped.
After each clip recompute outcodefor appropriate endpoint.
Cohen-Sutherland Algorithm / Solution Clipping 12/16
Solution: Outline
Each 1 bit in the outcode corresponds to a crossed boundary.
TBRL
0000
0000
01001
2
3
While not trivial acceptance or rejection:
Clip segment to boundaries in turn.A 1 in the outcode indicates thatend of the line should be clipped.
After each clip recompute outcodefor appropriate endpoint.
Cohen-Sutherland Algorithm / Solution Clipping 12/16
Solution: Outline
Each 1 bit in the outcode corresponds to a crossed boundary.
TBRL
0000
0000
01001
2
3
While not trivial acceptance or rejection:
Clip segment to boundaries in turn.A 1 in the outcode indicates thatend of the line should be clipped.
After each clip recompute outcodefor appropriate endpoint.
Cohen-Sutherland Algorithm / Solution Clipping 12/16
Solution: Green Line
TBRL
0001
1000
OutcodeInitial 0001 and 1000 = 0000
Clip left 1000 and 1000 = 10001000 or 1000 = 1000Trivial Rejection
Cohen-Sutherland Algorithm / Solution: Green Line Clipping 13/16
Solution: Green Line
TBRL
0001
1000
OutcodeInitial 0001 and 1000 = 0000
Clip left 1000 and 1000 = 10001000 or 1000 = 1000Trivial Rejection
Cohen-Sutherland Algorithm / Solution: Green Line Clipping 13/16
Solution: Green Line
TBRL
0001
1000
OutcodeInitial 0001 and 1000 = 0000
Clip left 1000 and 1000 = 10001000 or 1000 = 1000Trivial Rejection
Cohen-Sutherland Algorithm / Solution: Green Line Clipping 13/16
Solution: Green Line
TBRL
0001
1000
OutcodeInitial 0001 and 1000 = 0000
Clip left 1000 and 1000 = 10001000 or 1000 = 1000Trivial Rejection
Cohen-Sutherland Algorithm / Solution: Green Line Clipping 13/16
Solution: Green Line
TBRL
0001
1000
OutcodeInitial 0001 and 1000 = 0000
Clip left 1000 and 1000 = 10001000 or 1000 = 1000Trivial Rejection
Cohen-Sutherland Algorithm / Solution: Green Line Clipping 13/16
Solution: Green Line
TBRL
1000
10001
OutcodeInitial 0001 and 1000 = 0000
Clip left 1000 and 1000 = 10001000 or 1000 = 1000Trivial Rejection
Cohen-Sutherland Algorithm / Solution: Green Line Clipping 13/16
Solution: Green Line
TBRL
1000
10001
OutcodeInitial 0001 and 1000 = 0000
Clip left 1000 and 1000 = 10001000 or 1000 = 1000Trivial Rejection
Cohen-Sutherland Algorithm / Solution: Green Line Clipping 13/16
Solution: Green Line
TBRL
1000
10001
OutcodeInitial 0001 and 1000 = 0000
Clip left 1000 and 1000 = 10001000 or 1000 = 1000Trivial Rejection
Cohen-Sutherland Algorithm / Solution: Green Line Clipping 13/16
Solution: Green Line
TBRL
1000
10001
OutcodeInitial 0001 and 1000 = 0000
Clip left 1000 and 1000 = 10001000 or 1000 = 1000Trivial Rejection
Cohen-Sutherland Algorithm / Solution: Green Line Clipping 13/16
Solution: Red Line
TBRL
0101
1010
OutcodesInitial 0100 and 1010
= 0000
Clip left 0100 and 1010
= 0000
Clip right 0100 and 0000
= 0000
Clip bottom 0000 or 0000
= 0000
Trivial Acceptance
Cohen-Sutherland Algorithm / Solution: Red Line Clipping 14/16
Solution: Red Line
TBRL
0101
1010
OutcodesInitial 0100 and 1010
= 0000
Clip left 0100 and 1010
= 0000
Clip right 0100 and 0000
= 0000
Clip bottom 0000 or 0000
= 0000
Trivial Acceptance
Cohen-Sutherland Algorithm / Solution: Red Line Clipping 14/16
Solution: Red Line
TBRL
0101
1010
OutcodesInitial 0100 and 1010
= 0000
Clip left 0100 and 1010
= 0000
Clip right 0100 and 0000
= 0000
Clip bottom 0000 or 0000
= 0000
Trivial Acceptance
Cohen-Sutherland Algorithm / Solution: Red Line Clipping 14/16
Solution: Red Line
TBRL
0101
1010
OutcodesInitial 0100 and 1010
= 0000
Clip left 0100 and 1010
= 0000
Clip right 0100 and 0000
= 0000
Clip bottom 0000 or 0000
= 0000
Trivial Acceptance
Cohen-Sutherland Algorithm / Solution: Red Line Clipping 14/16
Solution: Red Line
TBRL
0101
1010
OutcodesInitial 0100 and 1010 = 0000
Clip left 0100 and 1010
= 0000
Clip right 0100 and 0000
= 0000
Clip bottom 0000 or 0000
= 0000
Trivial Acceptance
Cohen-Sutherland Algorithm / Solution: Red Line Clipping 14/16
Solution: Red Line
TBRL
1010
10100
OutcodesInitial 0100 and 1010 = 0000
Clip left 0100 and 1010
= 0000
Clip right 0100 and 0000
= 0000
Clip bottom 0000 or 0000
= 0000
Trivial Acceptance
Cohen-Sutherland Algorithm / Solution: Red Line Clipping 14/16
Solution: Red Line
TBRL
1010
10100
OutcodesInitial 0100 and 1010 = 0000
Clip left 0100 and 1010 = 0000Clip right 0100 and 0000
= 0000
Clip bottom 0000 or 0000
= 0000
Trivial Acceptance
Cohen-Sutherland Algorithm / Solution: Red Line Clipping 14/16
Solution: Red Line
TBRL
1
20000
0100
OutcodesInitial 0100 and 1010 = 0000
Clip left 0100 and 1010 = 0000Clip right 0100 and 0000
= 0000
Clip bottom 0000 or 0000
= 0000
Trivial Acceptance
Cohen-Sutherland Algorithm / Solution: Red Line Clipping 14/16
Solution: Red Line
TBRL
1
20000
0100
OutcodesInitial 0100 and 1010 = 0000
Clip left 0100 and 1010 = 0000Clip right 0100 and 0000 = 0000
Clip bottom 0000 or 0000
= 0000
Trivial Acceptance
Cohen-Sutherland Algorithm / Solution: Red Line Clipping 14/16
Solution: Red Line
TBRL
20000
3
0000
OutcodesInitial 0100 and 1010 = 0000
Clip left 0100 and 1010 = 0000Clip right 0100 and 0000 = 0000
Clip bottom 0000 or 0000
= 0000
Trivial Acceptance
Cohen-Sutherland Algorithm / Solution: Red Line Clipping 14/16
Solution: Red Line
TBRL
20000
3
0000
OutcodesInitial 0100 and 1010 = 0000
Clip left 0100 and 1010 = 0000Clip right 0100 and 0000 = 0000
Clip bottom 0000 or 0000 = 0000Trivial Acceptance
Cohen-Sutherland Algorithm / Solution: Red Line Clipping 14/16
Solution: Red Line
TBRL
20000
3
0000
OutcodesInitial 0100 and 1010 = 0000
Clip left 0100 and 1010 = 0000Clip right 0100 and 0000 = 0000
Clip bottom 0000 or 0000 = 0000Trivial Acceptance
Cohen-Sutherland Algorithm / Solution: Red Line Clipping 14/16
Line clipping
Cohen-Sutherland
Reduces intersection calculations by identify clippingboundaries.Easily extended to three dimensions (clipping to a box).
but Some line segments are clipped more than once beforeacceptance or rejection.
AlternativesLiang-Barsky fewer intersection calculations.
works in 3D.can be extended to convex polygons.
Nicholl-Lee-Nicholl efficient in 2D; cannot be extended to 3D.
See: Hearn & Baker, section 6.5 onwardsFoley, van Dam, Steiner, Hughes
Cohen-Sutherland Algorithm / Advanced Line Clipping Clipping 15/16
Line clipping
Cohen-Sutherland
Reduces intersection calculations by identify clippingboundaries.Easily extended to three dimensions (clipping to a box).
but Some line segments are clipped more than once beforeacceptance or rejection.
AlternativesLiang-Barsky fewer intersection calculations.
works in 3D.can be extended to convex polygons.
Nicholl-Lee-Nicholl efficient in 2D; cannot be extended to 3D.
See: Hearn & Baker, section 6.5 onwardsFoley, van Dam, Steiner, Hughes
Cohen-Sutherland Algorithm / Advanced Line Clipping Clipping 15/16
Line clipping
Cohen-Sutherland
Reduces intersection calculations by identify clippingboundaries.Easily extended to three dimensions (clipping to a box).
but Some line segments are clipped more than once beforeacceptance or rejection.
AlternativesLiang-Barsky fewer intersection calculations.
works in 3D.can be extended to convex polygons.
Nicholl-Lee-Nicholl efficient in 2D; cannot be extended to 3D.
See: Hearn & Baker, section 6.5 onwardsFoley, van Dam, Steiner, Hughes
Cohen-Sutherland Algorithm / Advanced Line Clipping Clipping 15/16
Line clipping
Cohen-Sutherland
Reduces intersection calculations by identify clippingboundaries.Easily extended to three dimensions (clipping to a box).
but Some line segments are clipped more than once beforeacceptance or rejection.
AlternativesLiang-Barsky fewer intersection calculations.
works in 3D.can be extended to convex polygons.
Nicholl-Lee-Nicholl efficient in 2D; cannot be extended to 3D.
See: Hearn & Baker, section 6.5 onwardsFoley, van Dam, Steiner, Hughes
Cohen-Sutherland Algorithm / Advanced Line Clipping Clipping 15/16
Line clipping
Cohen-Sutherland
Reduces intersection calculations by identify clippingboundaries.Easily extended to three dimensions (clipping to a box).
but Some line segments are clipped more than once beforeacceptance or rejection.
AlternativesLiang-Barsky fewer intersection calculations.
works in 3D.can be extended to convex polygons.
Nicholl-Lee-Nicholl efficient in 2D; cannot be extended to 3D.
See: Hearn & Baker, section 6.5 onwardsFoley, van Dam, Steiner, Hughes
Cohen-Sutherland Algorithm / Advanced Line Clipping Clipping 15/16
Line clipping
Cohen-Sutherland
Reduces intersection calculations by identify clippingboundaries.Easily extended to three dimensions (clipping to a box).
but Some line segments are clipped more than once beforeacceptance or rejection.
AlternativesLiang-Barsky fewer intersection calculations.
works in 3D.can be extended to convex polygons.
Nicholl-Lee-Nicholl efficient in 2D; cannot be extended to 3D.
See: Hearn & Baker, section 6.5 onwardsFoley, van Dam, Steiner, Hughes
Cohen-Sutherland Algorithm / Advanced Line Clipping Clipping 15/16
Line clipping
Cohen-Sutherland
Reduces intersection calculations by identify clippingboundaries.Easily extended to three dimensions (clipping to a box).
but Some line segments are clipped more than once beforeacceptance or rejection.
AlternativesLiang-Barsky fewer intersection calculations.
works in 3D.can be extended to convex polygons.
Nicholl-Lee-Nicholl efficient in 2D; cannot be extended to 3D.
See: Hearn & Baker, section 6.5 onwardsFoley, van Dam, Steiner, Hughes
Cohen-Sutherland Algorithm / Advanced Line Clipping Clipping 15/16
Line clipping
Cohen-Sutherland
Reduces intersection calculations by identify clippingboundaries.Easily extended to three dimensions (clipping to a box).
but Some line segments are clipped more than once beforeacceptance or rejection.
AlternativesLiang-Barsky fewer intersection calculations.
works in 3D.can be extended to convex polygons.
Nicholl-Lee-Nicholl efficient in 2D; cannot be extended to 3D.
See: Hearn & Baker, section 6.5 onwardsFoley, van Dam, Steiner, Hughes
Cohen-Sutherland Algorithm / Advanced Line Clipping Clipping 15/16
Line clipping
Cohen-Sutherland
Reduces intersection calculations by identify clippingboundaries.Easily extended to three dimensions (clipping to a box).
but Some line segments are clipped more than once beforeacceptance or rejection.
AlternativesLiang-Barsky fewer intersection calculations.
works in 3D.can be extended to convex polygons.
Nicholl-Lee-Nicholl efficient in 2D; cannot be extended to 3D.
See: Hearn & Baker, section 6.5 onwardsFoley, van Dam, Steiner, Hughes
Cohen-Sutherland Algorithm / Advanced Line Clipping Clipping 15/16
Line clipping
Cohen-Sutherland
Reduces intersection calculations by identify clippingboundaries.Easily extended to three dimensions (clipping to a box).
but Some line segments are clipped more than once beforeacceptance or rejection.
AlternativesLiang-Barsky fewer intersection calculations.
works in 3D.can be extended to convex polygons.
Nicholl-Lee-Nicholl efficient in 2D; cannot be extended to 3D.
See: Hearn & Baker, section 6.5 onwardsFoley, van Dam, Steiner, Hughes
Cohen-Sutherland Algorithm / Advanced Line Clipping Clipping 15/16
Line clipping
Cohen-Sutherland
Reduces intersection calculations by identify clippingboundaries.Easily extended to three dimensions (clipping to a box).
but Some line segments are clipped more than once beforeacceptance or rejection.
AlternativesLiang-Barsky fewer intersection calculations.
works in 3D.can be extended to convex polygons.
Nicholl-Lee-Nicholl efficient in 2D; cannot be extended to 3D.
See: Hearn & Baker, section 6.5 onwardsFoley, van Dam, Steiner, Hughes
Cohen-Sutherland Algorithm / Advanced Line Clipping Clipping 15/16
Line Clipping to Concave Polygons
Split concave polygon intounion of convex polygons.
Clip to each convexpolygon in turn.
Liang-Barsky clipping foreach polygon.
Most efficient to chooselarge polygons.
Line Clipping to Concave Polygons Clipping 16/16
Line Clipping to Concave Polygons
Split concave polygon intounion of convex polygons.
Clip to each convexpolygon in turn.
Liang-Barsky clipping foreach polygon.
Most efficient to chooselarge polygons.
Line Clipping to Concave Polygons Clipping 16/16
Line Clipping to Concave Polygons
Split concave polygon intounion of convex polygons.
Clip to each convexpolygon in turn.
Liang-Barsky clipping foreach polygon.
Most efficient to chooselarge polygons.
Line Clipping to Concave Polygons Clipping 16/16
Line Clipping to Concave Polygons
Split concave polygon intounion of convex polygons.
Clip to each convexpolygon in turn.
Liang-Barsky clipping foreach polygon.
Most efficient to chooselarge polygons.
Line Clipping to Concave Polygons Clipping 16/16
Line Clipping to Concave Polygons
Split concave polygon intounion of convex polygons.
Clip to each convexpolygon in turn.
Liang-Barsky clipping foreach polygon.
Most efficient to chooselarge polygons.
Line Clipping to Concave Polygons Clipping 16/16
Line Clipping to Concave Polygons
Split concave polygon intounion of convex polygons.
Clip to each convexpolygon in turn.
Liang-Barsky clipping foreach polygon.
Most efficient to chooselarge polygons.
Line Clipping to Concave Polygons Clipping 16/16