Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chi-Cheng Lin, Winona State University CS430 Computer Graphics Vectors Part IV Polygon Intersection.

Similar presentations


Presentation on theme: "Chi-Cheng Lin, Winona State University CS430 Computer Graphics Vectors Part IV Polygon Intersection."— Presentation transcript:

1 Chi-Cheng Lin, Winona State University CS430 Computer Graphics Vectors Part IV Polygon Intersection

2 2 Topics l Polygon Intersection Problems l Convex Polygons and Polyhedra l Ray Intersection and Clipping l Cyrus-Beck Clipping Algorithm

3 3 Polygon Intersection Problems l Polygons are fundamental objects in both 2D and 3D graphics l A polygonal mesh can be used to model a 3D graphics object l Polyhedron zA polygonal mesh which forms a closed surface that encloses some space

4 4 Polygon Intersection Problems l Is a given point P inside or outside the object? l Where does a given ray R first intersect the object? l Which part of a given line L lies inside/outside the object?

5 5 Polygon Intersection Problems

6 6 Convex Polygons and Polyhedra l General case of polygon/polyhedron intersection problems is complex l Convex polygons/polyhedra are easier to deal with z2D: a convex polygon can be completely described by a set of “bounding lines” z3D: a convex polyhedron can be completely described by a set of “bounding planes”  Deal with bounding lines/planes

7 7 Convex Polygons and Polyhedra

8 8 l Outward normal zEvery bounding line of a 2D convex polygon zEvery bounding plane of a 3D convex polyhedron

9 9 Convex Polygons and Polyhedra l Outside half-space l Polyhedron zIntersection of all the inside half-spaces L1L1 Outside half-space Inside half-space

10 10 Ray Intersection l A Intersection problem: when does a ray enter and exit a convex polygon? l A ray A + ct hits a convex polygon P exactly twice zEntering hit point: A + ct in zExiting hit point: A + ct out zThe ray is inside P for all t  [t in, t out ] A c P

11 11 Clipping l Clipping problem: given points A and C, which part of line segment AC lies inside a convex polygon P ? l A’ = A + c max(0, t in ) C’ = A + c min(t out, 1) AP C 0 t in t out 1 A 0 t in t out C 1 A 0 t in t out C 1

12 12 Clipping l How are t in and t out computed? zWe must find the intersection of the ray and each bounding line in turn l Assume a bounding line is represented as {B, n}, where zB: some point on the line zn: outward normal

13 13 Clipping If n  c > 0, ray is exiting from P If n  c = 0, ray is parallel to P If n  c < 0, ray is entering P l For each bounding line, find z Hit time of the ray with bounding line z Whether the ray is entering or exiting n1n1 c A B1B1 B2B2 n2n2

14 14 Clipping l Approach zCandidate interval of t : [t in, t out ] zKeep track of the maximum entering time t in zKeep track of the minimum exit time t out zWe want to chop the interval at each iteration zCan stop as soon as t in > t out (what does this mean?)

15 15 Clipping - Algorithm Initialize [t in, t out ]  [0, 1] for each boundary find the hit time t hit if entering then t in = max(t in, t hit ) else t out = min(t out, t hit ) if t in > t out then no intersection  stop segment from A + ct in to A + ct out lies inside P (We found: endpoints of clipped lines entering and exiting points of ray)

16 16 Clipping - Example Updates on t in and t out : Line test t in t out 000.83 100.66 20 0.66 300.66 40.20.66 50.280.66 L0L0 L1L1 L2L2 L3L3 L4L4 L5L5 A C @0 @1 @.2 @.28 @.66 @.83 @3.4 @-4.7

17 17 Cyrus-Beck Clipping Algorithm l Clip a line segment against any convex polygon l Input parameters zLine segment zList of bounding lines l Output parameter zClipped line segment l Return value z1, if part of segment lies in P z0, otherwise

18 18

19 19


Download ppt "Chi-Cheng Lin, Winona State University CS430 Computer Graphics Vectors Part IV Polygon Intersection."

Similar presentations


Ads by Google