28
Classes of Polygons • Planar polygons – Simple • Convex • Star-shaped – Non-simple • Non-planar polygons

Classes of Polygons Planar polygons –Simple Convex Star-shaped –Non-simple Non-planar polygons

Embed Size (px)

Citation preview

Page 1: Classes of Polygons Planar polygons –Simple Convex Star-shaped –Non-simple Non-planar polygons

Classes of Polygons

• Planar polygons– Simple

• Convex

• Star-shaped

– Non-simple

• Non-planar polygons

Page 2: Classes of Polygons Planar polygons –Simple Convex Star-shaped –Non-simple Non-planar polygons

Planar Polygons

• Definition:All points of the polygon must lie within a plane.

Page 3: Classes of Polygons Planar polygons –Simple Convex Star-shaped –Non-simple Non-planar polygons

Simple Polygons

• DefinitionA polygon P is simple, if no two non-consecutive

edges intersect.

Simple Not simple

Page 4: Classes of Polygons Planar polygons –Simple Convex Star-shaped –Non-simple Non-planar polygons

Simple Polygons

• The polygon interior is well-defined. If we traverse the polygon in a counter-clockwise direction, the interior is always to our left.

Simple Not simple

Page 5: Classes of Polygons Planar polygons –Simple Convex Star-shaped –Non-simple Non-planar polygons

Convex Polygons

• DefinitionA polygon P is convex, if and only if, for any pair of

points x,y, in P the line segment between x and y lies entirely in P.

Every point can see every other point.

Convex Concave

Page 6: Classes of Polygons Planar polygons –Simple Convex Star-shaped –Non-simple Non-planar polygons

Convex Polygons

• Alternative DefinitionGoing from point Pi to Pi+1 involves making only left

had turns.

Implies that the polygon vertices are ordered in a counter-clockwise fashion.

Implies cross-products of adjacent edges are positive.

• Convex polygons are of course, simple.

Page 7: Classes of Polygons Planar polygons –Simple Convex Star-shaped –Non-simple Non-planar polygons

Triangles

• Any three non-colinear points determine a triangle.– Planar– Convex

• Cross products can determine the normal (A,B,C)T to the triangle (plane).

• Plane: Ax + By + Cz + D = 0, where D can be solved using any of the three points.

Page 8: Classes of Polygons Planar polygons –Simple Convex Star-shaped –Non-simple Non-planar polygons

Star-Shaped Polygons

• DefinitionA star-shaped polygon, P, is a simple polygon which

contains a non-empty set, K of points, such that every point in K is visible from any other point in the polygon. The set K is called the kernel of P.

A convex polygon is a star-shaped polygon whose kernel is equal to the interior of P.

Page 9: Classes of Polygons Planar polygons –Simple Convex Star-shaped –Non-simple Non-planar polygons

Star-Shaped Polygons

• The kernel can easily be determined by clipping the polygon to the half-planes defined by each edge.

Page 10: Classes of Polygons Planar polygons –Simple Convex Star-shaped –Non-simple Non-planar polygons

Non-Planar Polygons

• In 3D computer graphics, we often have to deal with non-planar polygons.– Longitude/latitude grid on a sphere.– Polygonal approximations to smooth surfaces.

Page 11: Classes of Polygons Planar polygons –Simple Convex Star-shaped –Non-simple Non-planar polygons

More Polygonal Definitions

• Convex Hull – The convex hull of a polygon P, is the smallest convex polygon that contains P.

• Diagonal – A line segment lying entirely inside polygon P and joining two non-consecutive vertices pi and pk

• Principal vertex – A vertex pi of simple polygon P is called a principal vertex if the diagonal (pi-1, pi+1) intersects the boundary of P only at pi-1 and pi+1.

diagonal

Not a principal vertex

Convex hull

Page 12: Classes of Polygons Planar polygons –Simple Convex Star-shaped –Non-simple Non-planar polygons

More Polygonal Definitions

• Ear – A principal vertex pi of a simple polygon P is called an ear if the diagonal (pi-1, pi+1) lies in the interior of P.

• Mouth – A principal vertex pi of a simple polygon P is called a mouth if the diagonal (pi-1, pi+1) lies in the exterior of P.

Page 13: Classes of Polygons Planar polygons –Simple Convex Star-shaped –Non-simple Non-planar polygons

Some Theorems

• One-Mouth Theorem – Except for convex polygons, every simple polygon has at least one mouth.

• Two-Ears Theorem – Except for triangles, every simple polygon has at least two non-overlapping ears.

Page 14: Classes of Polygons Planar polygons –Simple Convex Star-shaped –Non-simple Non-planar polygons

Polygonal Tricks

• Area

• Test for concave/convex.

Page 15: Classes of Polygons Planar polygons –Simple Convex Star-shaped –Non-simple Non-planar polygons

Polygonal Area

• Convex polygonsTake any point inside the polygon and

compute the area of all triangles formed with one edge and the point.

Actually, we can take any point and do this, if we give the area of the triangles a signed value.

Page 16: Classes of Polygons Planar polygons –Simple Convex Star-shaped –Non-simple Non-planar polygons

Triangle Area

• The good old cross product:||AB|| = area of parallel-piped

= 2*area of triangle.

For 2D triangles, the magnitude is the absolute value ofthe z-component.

A

B

Area = ½AxBy-AyBx

Page 17: Classes of Polygons Planar polygons –Simple Convex Star-shaped –Non-simple Non-planar polygons

Polygonal Area

• Vectors: Choose the point to be the origin, then the vectors are simply the points on the polygon.

• Convex polygon

Area =

1

0112

1n

iiiii yxyx

Page 18: Classes of Polygons Planar polygons –Simple Convex Star-shaped –Non-simple Non-planar polygons

Polygonal Area

• Wow!!! This actually works for any simple polygon.

Page 19: Classes of Polygons Planar polygons –Simple Convex Star-shaped –Non-simple Non-planar polygons

Convexity Test

• We can easily determine whether a polygon is convex or concave, and whether it is order clockwise or counter-clockwise.– Examine the cross products between adjacent

edges. If they are all the same sign, then the polygon is convex, otherwise it is concave.

– If the area computed as before is positive, then the ordering is in a counter-clockwise fashion.

Page 20: Classes of Polygons Planar polygons –Simple Convex Star-shaped –Non-simple Non-planar polygons

Efficient Scan-Conversion

• Convex polygons

• Triangles

Page 21: Classes of Polygons Planar polygons –Simple Convex Star-shaped –Non-simple Non-planar polygons

Scan-Converting Convex Polygons

• What is the intersection of a line with a convex polygon?

Page 22: Classes of Polygons Planar polygons –Simple Convex Star-shaped –Non-simple Non-planar polygons

Scan-Converting Convex Polygons

• Any line will intersect a convex polygon in at most 2 locations.– This greatly simplifies our active edge table.– Simply keep a current x-left

and an x-right intersection.– Update the slopes on scan-

lines where new edgesstart.

Page 23: Classes of Polygons Planar polygons –Simple Convex Star-shaped –Non-simple Non-planar polygons

Scan-Converting Triangles

• Special casesOne horizontal edge.

• For y=ymin to ymaxDraw from x-left to x-right

Update x-left and x-right

Page 24: Classes of Polygons Planar polygons –Simple Convex Star-shaped –Non-simple Non-planar polygons

Scan-Converting Triangles

• General cases:

• Divide into two special cases.

• One quick split at middle vertex and 2 very tight for loops.

Page 25: Classes of Polygons Planar polygons –Simple Convex Star-shaped –Non-simple Non-planar polygons

Triangulations

• To avoid problems with non-planar polygons, as well as simplify the scan-conversion process, we can triangulate a polygon before we rasterize it.

• A triangulation of a simple polygon P consists of n-3 diagonals, or n-2 triangles.

Page 26: Classes of Polygons Planar polygons –Simple Convex Star-shaped –Non-simple Non-planar polygons

Triangulation Algorithms

• Convex polygons are trivial.

• Star-shaped polygons can also be dealt with rather easily.

• Can also use splitting algorithms as described in the book. These add additional vertices, but may be simpler.

Page 27: Classes of Polygons Planar polygons –Simple Convex Star-shaped –Non-simple Non-planar polygons

Triangulating Convex Polygons

• Pick any vertex i.

• Connect the vertices (i,k,k+1) for all k i, i-1.

Page 28: Classes of Polygons Planar polygons –Simple Convex Star-shaped –Non-simple Non-planar polygons

Triangulating Concave Polygons

While polygon P is not a triangleFind an ear of P.

Remove the ear from P.