2d 3d clipping l.
Download
Skip this Video
Download Presentation
2D, 3D Clipping

Loading in 2 Seconds...

play fullscreen
1 / 20

2D, 3D Clipping - PowerPoint PPT Presentation


  • 317 Views
  • Uploaded on

2D, 3D Clipping. Soon Tee Teoh CS 116A. Line Clipping. Point clipping easy: Just check the inequalities x min < x < x max y min < y < y max Line clipping more tricky. Cohen-Sutherland Line Clipping. Divide 2D space into 3x3 regions. Middle region is the clipping window.

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about '2D, 3D Clipping' - latona


Download Now An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
2d 3d clipping

2D, 3D Clipping

Soon Tee Teoh

CS 116A

line clipping
Line Clipping
  • Point clipping easy: Just check the inequalities
    • xmin < x < xmax
    • ymin < y < ymax
  • Line clipping more tricky
cohen sutherland line clipping
Cohen-Sutherland Line Clipping
  • Divide 2D space into 3x3 regions.
  • Middle region is the clipping window.
  • Each region is assigned a 4-bit code.
  • Bit 1 is set to 1 if the region is to the left of the clipping window, 0 otherwise. Similarly for bits 2, 3 and 4.

4

3

2

1

Top Bottom Right Left

cohen sutherland line clipping4
Cohen-Sutherland Line Clipping

1000

1010

1001

0000

0010

0001

0100

0110

0101

cohen sutherland line clipping5
Cohen-Sutherland Line Clipping
  • To clip a line, find out which regions its two endpoints lie in.
  • If they are both in region 0000, then it’s completely in.
  • If the two region numbers both have a 1 in the same bit position, the line is completely out.
  • Otherwise, we have to do some more calculations.
cohen sutherland line clipping6
Cohen-Sutherland Line Clipping
  • For those lines that we cannot immediately determine, we successively clip against each boundary.
  • Then check the new endpoint for its region code.
  • How to find boundary intersection: To find y coordinate at vertical intersection, substitute x value at the boundary into the line equation of the line to be clipped.
  • Other algorithms:
    • Faster: Cyrus-Beck
    • Even faster: Liang-Barsky
    • Even faster: Nichol-Lee-Nichol
polygon fill area clipping8
Polygon Fill-Area Clipping

v1

v1”

v1’

v3’

v3”

v3

v2

v2

Note: Need to consider each of 4 edge boundaries

sutherland hodgman polygon clipping
Sutherland-HodgmanPolygon Clipping
  • Input each edge (vertex pair) successively.
  • Output is a new list of vertices.
  • Each edge goes through 4 clippers.
  • The rule for each edge for each clipper is:
    • If first input vertex is outside, and second is inside, output the intersection and the second vertex
    • If first both input vertices are inside, then just output second vertex
    • If first input vertex is inside, and second is outside, output is the intersection
    • If both vertices are outside, output is nothing
sutherland hodgman polygon clipping four possible scenarios at each clipper
Sutherland-Hodgman Polygon Clipping: Four possible scenarios at each clipper

outside inside

outside inside

outside inside

outside inside

v2

v2

v2

v2

v1’

v1’

v1

v1

v1

v1

Outside to inside:

Output: v1’ and v2

Inside to inside:

Output: v2

Inside to outside:

Output: v1’

Outside to outside:

Output: nothing

sutherland hodgman polygon clipping11
Sutherland-Hodgman Polygon Clipping

v2’

Figure 6-27, page 332

v2

v3

v1’

v3’

Left

Clipper

Right

Clipper

Bottom

Clipper

Top

Clipper

v1

v2”

v2’v3’

v2”v1’

v1’

v2v2’

v2’

v2

v1v2

v2

v2’v3’

v3’

v3’v1

v1’v2

v2’

v2v3

v2’

v3’v1

v3’v1

v1

v1v2

v1’v2

v2v2’

v3v1

v2”

v1v2

v2

v2v2’

v2’v2”

v2’

Edges Output

Edges Output

Edges Output

Edges Output

Final

weiler atherton polygon clipping
Weiler-Atherton Polygon Clipping

Sutherland-Hodgman

Weiler-Atherton

clipping in 3d
Clipping in 3D
  • Suppose the view volume has been normalized. Then the clipping boundaries are just:

xwmin = -1

ywmin = -1

zwmin = -1

xwmax = 1

ywmax = 1

zwmax = 1

clipping homogeneous coordinates in 3d
Clipping Homogeneous Coordinates in 3D
  • Coordinates expressed in homogeneous coordinates
  • After geometric, viewing and projection transformations, each vertex is: (xh, yh, zh, h)
  • Therefore, assuming coordinates have been normalized to a (-1,1) volume, a point (xh, yh, zh, h) is inside the view volume if:

xh

yh

zh

-1 < < 1 and -1 < < 1 and -1 < < 1

h

h

h

Suppose that h > 0, which is true in normal cases, then

-h < xh < h and -h < yh < h and -h < zh < h

remember cohen sutherland 2d line clipping region codes
Remember Cohen-Sutherland 2D Line Clipping Region Codes?
  • Divide 2D space into 3x3 regions.
  • Middle region is the clipping window.
  • Each region is assigned a 4-bit code.
  • Bit 1 is set to 1 if the region is to the left of the clipping window, 0 otherwise. Similarly for bits 2, 3 and 4.

4

3

2

1

Top Bottom Right Left

cohen sutherland line clipping region codes in 2d
Cohen-Sutherland Line Clipping Region Codes in 2D

1000

1010

1001

0000

0010

0001

0100

0110

0101

3d cohen sutherland region codes
3D Cohen-Sutherland Region Codes
  • Simply use 6 bits instead of 4.

6

5

4

3

2

1

Far Near Top Bottom Right Left

Example: If h + xh < 0, then bit 1 is set to 1.

This is because if -h > xh, then the point is to the left of the viewing volume.

clipping polygons
Clipping Polygons
  • First, perform trivial acceptance and rejection using, for example, its coordinate extents.
  • Polygons usually split into triangle strips.
  • Then each triangle is clipped using 3D extension of the Sutherland-Hodgman method
arbitrary clipping planes
Arbitrary Clipping Planes
  • Can specify an arbitrary clipping plane: Ax + By + Cz + D = 0.
  • Therefore, for any point, if Ax + By + Cz + D < 0, it is not shown.
  • To clip a line against an arbitrary plane,
    • If both end-points are in, then the line is in
    • If both end-points are out, then the line is out
    • If one end-point is in, and one is out, then we need to find the intersection of the line and the plane
intersection of line and plane
Intersection of Line and Plane
  • First, given two end-points of a line, P1 and P2, form a parametric representation of the line:

P = P1 + (P2 – P1) u, where 0<u<1

Equation of the clipping plane: N.P + D = 0, where N = (A,B,C)

Substituting, N.(P1 + (P2 – P1)u) + D = 0

– D – N.P1

N . (P2 – P1)

u =

ad