1 filling graphical shapes. 2 we know how to draw outlines can we just fill the “inside”? …but...
TRANSCRIPT
![Page 1: 1 Filling Graphical Shapes. 2 We know how to draw outlines Can we just fill the “inside”? …but how do we know the difference between the inside and outside?](https://reader036.vdocuments.us/reader036/viewer/2022072015/56649ec85503460f94bd5c48/html5/thumbnails/1.jpg)
1
Filling Graphical Shapes
![Page 2: 1 Filling Graphical Shapes. 2 We know how to draw outlines Can we just fill the “inside”? …but how do we know the difference between the inside and outside?](https://reader036.vdocuments.us/reader036/viewer/2022072015/56649ec85503460f94bd5c48/html5/thumbnails/2.jpg)
2
We know how to draw outlines
Can we just fill the “inside”? …but how do we know the difference
between the inside and outside? Can we determine if a point is inside a shape?
![Page 3: 1 Filling Graphical Shapes. 2 We know how to draw outlines Can we just fill the “inside”? …but how do we know the difference between the inside and outside?](https://reader036.vdocuments.us/reader036/viewer/2022072015/56649ec85503460f94bd5c48/html5/thumbnails/3.jpg)
3
A Filling Anomaly
![Page 4: 1 Filling Graphical Shapes. 2 We know how to draw outlines Can we just fill the “inside”? …but how do we know the difference between the inside and outside?](https://reader036.vdocuments.us/reader036/viewer/2022072015/56649ec85503460f94bd5c48/html5/thumbnails/4.jpg)
CS-321Dr. Mark L. Hornick
4
One Approach:The Odd-Even Rule
1. Choose an arbitrary point
2. Draw ray to a distant point Don’t intersect any vertices What’s a “distant” point?
3. Count edges crossed Odd count means interior Even count means exterior
1
1
1
3
2
0
2
![Page 5: 1 Filling Graphical Shapes. 2 We know how to draw outlines Can we just fill the “inside”? …but how do we know the difference between the inside and outside?](https://reader036.vdocuments.us/reader036/viewer/2022072015/56649ec85503460f94bd5c48/html5/thumbnails/5.jpg)
CS-321Dr. Mark L. Hornick
5
Odd-Even Result
1
1
1
1
3
2
![Page 6: 1 Filling Graphical Shapes. 2 We know how to draw outlines Can we just fill the “inside”? …but how do we know the difference between the inside and outside?](https://reader036.vdocuments.us/reader036/viewer/2022072015/56649ec85503460f94bd5c48/html5/thumbnails/6.jpg)
CS-321Dr. Mark L. Hornick
6
Another approach:Nonzero Winding Rule Choose a point Draw ray to a distant point
Don’t intersect any vertices Consider edges crossed
(right hand rule) Subtract 1 when ray to edge
is clockwise Add 1 when ray to edge is
counter-clockwise Nonzero count means
interior Count = “Winding number”
-1
-1
-1
-1
-2
0
0
![Page 7: 1 Filling Graphical Shapes. 2 We know how to draw outlines Can we just fill the “inside”? …but how do we know the difference between the inside and outside?](https://reader036.vdocuments.us/reader036/viewer/2022072015/56649ec85503460f94bd5c48/html5/thumbnails/7.jpg)
CS-321Dr. Mark L. Hornick
7
Nonzero Winding Example
−1
−1
−1
−1
−1
−2
![Page 8: 1 Filling Graphical Shapes. 2 We know how to draw outlines Can we just fill the “inside”? …but how do we know the difference between the inside and outside?](https://reader036.vdocuments.us/reader036/viewer/2022072015/56649ec85503460f94bd5c48/html5/thumbnails/8.jpg)
CS-321Dr. Mark L. Hornick
8
Computing Winding Number
Compute cross product Between ray and edge Sign of z value determines direction
+z implies CCW (add 1 to winding number)
See text, page 128
![Page 9: 1 Filling Graphical Shapes. 2 We know how to draw outlines Can we just fill the “inside”? …but how do we know the difference between the inside and outside?](https://reader036.vdocuments.us/reader036/viewer/2022072015/56649ec85503460f94bd5c48/html5/thumbnails/9.jpg)
CS-321Dr. Mark L. Hornick
9
Cross Product Example
u=(1,1,0)
VB=(2,0,0)
VA=(1,0,0) E
“−1” means u crosses E clockwise
![Page 10: 1 Filling Graphical Shapes. 2 We know how to draw outlines Can we just fill the “inside”? …but how do we know the difference between the inside and outside?](https://reader036.vdocuments.us/reader036/viewer/2022072015/56649ec85503460f94bd5c48/html5/thumbnails/10.jpg)
CS-321Dr. Mark L. Hornick
10
Cross Product Simplification
negative means clockwise
![Page 11: 1 Filling Graphical Shapes. 2 We know how to draw outlines Can we just fill the “inside”? …but how do we know the difference between the inside and outside?](https://reader036.vdocuments.us/reader036/viewer/2022072015/56649ec85503460f94bd5c48/html5/thumbnails/11.jpg)
CS-321Dr. Mark L. Hornick
11
Computing Winding Number
Compute dot product Use perpendicular to ray vs. edge
If ray is given by (ux, uy), perpendicular is (- uy, ux)
Sign of product determines direction +product implies “right-to-left” (add 1 to winding
number)
See text, page 128
![Page 12: 1 Filling Graphical Shapes. 2 We know how to draw outlines Can we just fill the “inside”? …but how do we know the difference between the inside and outside?](https://reader036.vdocuments.us/reader036/viewer/2022072015/56649ec85503460f94bd5c48/html5/thumbnails/12.jpg)
CS-321Dr. Mark L. Hornick
12
Dot Product Example
Again, “−1” means u crosses E from left to right
u=(1,1,0), w = (−1,1,0) [“right-to-left” perpendicular to u]
VB=(2,0,0)
VA=(1,0,0) E
![Page 13: 1 Filling Graphical Shapes. 2 We know how to draw outlines Can we just fill the “inside”? …but how do we know the difference between the inside and outside?](https://reader036.vdocuments.us/reader036/viewer/2022072015/56649ec85503460f94bd5c48/html5/thumbnails/13.jpg)
CS-321Dr. Mark L. Hornick
13
Dot Product Simplification
Same result as from cross product!
![Page 14: 1 Filling Graphical Shapes. 2 We know how to draw outlines Can we just fill the “inside”? …but how do we know the difference between the inside and outside?](https://reader036.vdocuments.us/reader036/viewer/2022072015/56649ec85503460f94bd5c48/html5/thumbnails/14.jpg)
CS-321Dr. Mark L. Hornick
14
Inside-Outside Tests Summary
Odd-even rule Generalized from scan-line fill May produce unusual results if edges
intersect Nonzero winding number rule
Alternate way of determining interior