chi-cheng lin, winona state university cs430 computer graphics vectors part iv polygon intersection
TRANSCRIPT
Chi-Cheng Lin, Winona State University
CS430 Computer Graphics
Vectors Part IVPolygon Intersection
2
Topics
Polygon Intersection Problems Convex Polygons and Polyhedra Ray Intersection and Clipping Cyrus-Beck Clipping Algorithm
3
Polygon Intersection Problems
Polygons are fundamental objects in both 2D and 3D graphics
A polygonal mesh can be used to model a 3D graphics object
PolyhedronA polygonal mesh which forms a closed
surface that encloses some space
4
Polygon Intersection Problems
Is a given point P inside or outside the object?
Where does a given ray R first intersect the object?
Which part of a given line L lies inside/outside the object?
5
Polygon Intersection Problems
6
Convex Polygons and Polyhedra
General case of polygon/polyhedron intersection problems is complex
Convex polygons/polyhedra are easier to deal with2D: a convex polygon can be completely
described by a set of “bounding lines”3D: a convex polyhedron can be
completely described by a set of “bounding planes”
Deal with bounding lines/planes
7
Convex Polygons and Polyhedra
8
Convex Polygons and Polyhedra
Outward normalEvery bounding line of a 2D convex
polygonEvery bounding plane of a 3D convex
polyhedron
9
Convex Polygons and Polyhedra
Outside half-space
PolyhedronIntersection of all the inside half-spaces
L1
Outside half-spaceInside
half-space
10
Ray Intersection A Intersection problem: when does
a ray enter and exit a convex polygon?
A ray A + ct hits a convex polygon P exactly twiceEntering hit point: A + ctin
Exiting hit point: A + ctout
The ray is inside P for all t [tin, tout]
Ac
P
11
Clipping Clipping problem: given points A
and C, which part of line segment AC lies inside a convex polygon P ?
A’ = A + c max(0, tin)
C’ = A + c min(tout, 1)
A PC0 tin
tout 1
A0 tin
tout
C1
A0tin
tout
C1
12
Clipping How are tin and tout computed?
We must find the intersection of the ray and each bounding line in turn
Assume a bounding line is represented as {B, n}, where B: some point on the linen: outward normal
13
Clipping If nc > 0, ray is exiting from P
If nc = 0, ray is parallel to PIf nc < 0, ray is entering P
For each bounding line, findHit time of the ray with bounding lineWhether the ray is entering or exiting
n1
cA B1 B2
n2
14
Clipping Approach
Candidate interval of t : [tin, tout ]Keep track of the maximum entering
time tin
Keep track of the minimum exit time tout
We want to chop the interval at each iteration
Can stop as soon as tin > tout (what does this mean?)
15
Clipping - AlgorithmInitialize [tin, tout] [0, 1]
for each boundaryfind the hit time thit
if entering then tin = max(tin, thit)
else tout = min(tout, thit)
if tin > tout then no intersection stop
segment from A + ctin to A + ctout lies inside P
(We found: endpoints of clipped lines entering and exiting points of ray)
16
Clipping - ExampleUpdates on tin and tout:
Line test tin tout
0 0 0.831 0 0.662 0 0.663 0 0.664 0.2 0.665 0.28 0.66
L0
L1
L2
L3
L4
L5 A
C
@0
@1
@.2
@.83
@3.4
@-4.7
17
Cyrus-Beck Clipping Algorithm Clip a line segment against any convex
polygon Input parameters
Line segmentList of bounding lines
Output parameterClipped line segment
Return value1, if part of segment lies in P0, otherwise
18
19