Filling Graphical Shapes - PowerPoint PPT Presentation

1 / 14
About This Presentation
Title:

Filling Graphical Shapes

Description:

Computing Winding Number. Compute cross product. Between ray and edge ... Nonzero winding number rule. Alternate way of determining interior ... – PowerPoint PPT presentation

Number of Views:320
Avg rating:3.0/5.0
Slides: 15
Provided by: ericd95
Category:

less

Transcript and Presenter's Notes

Title: Filling Graphical Shapes


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?
  • Can we determine if a point is inside a shape?

3
A Filling Anomaly
4
One ApproachThe Odd-Even Rule
0
  • Choose an arbitrary point
  • Draw ray to a distant point
  • Dont intersect any vertices
  • Whats a distant point?
  • Count edges crossed
  • Odd count means interior
  • Even count means exterior

1
2
1
3
1
2
5
Odd-Even Result
1
2
1
1
3
1
6
Another approachNonzero Winding Rule
0
  • Choose a point
  • Draw ray to a distant point
  • Dont 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
-2
-1
-1
-1
0
7
Nonzero Winding Example
-1
-2
-1
-1
-1
-1
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
9
Cross Product Example
-1 means u crosses E clockwise
10
Cross Product Simplification
negative means clockwise
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
12
Dot Product Example
13
Dot Product Simplification
Same result as from cross product!
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
Write a Comment
User Comments (0)
About PowerShow.com