cmsc427 points, polylines and polygons

19
CMSC427 Points, polylines and polygons

Upload: others

Post on 29-Oct-2021

2 views

Category:

Documents


0 download

TRANSCRIPT

CMSC427Points,polylinesandpolygons

•  Intheory,smoothcurve:

•  Inreality,piecewisediscreteapproxima@on:

Issue: discretization of continuous curve

Modeling with discrete approximations

Increase fidelity with more points

Points, polylines and polygons

Points Also called vertices

Polyline Continuous sequence

of line segments

Polygon Closed sequence of line segments

Polygon properties I

•  Simplenoself-intersec@onsnoduplicatepoints

• Non-simple self-intersections duplicate points

Polygon properties II

•  ConvexpolygonAnytwopointsinpolygoncanbeconnectedbyinsideline

• Concave polygon Not true of all point pairs inside polygon

Point in polygon problem

IsPinsideoroutsidethepolygon?

Case1 Case2

Case3

Point in polygon problem

IsPinsideoroutsidethepolygon?

Case1 Case2

Case3

1 crossing

3 crossings

2 crossings

Point in polygon problem

IsPinsideoroutsidethepolygon?Oddcrossings–insideEvencrossings–outside

Case1 Case2

Case3

1 crossing

3 crossings

2 crossings

Algorithmicefficiency?

Point in polygon problem

IsPinsideoroutsidethepolygon?

Point in polygon problem

IsPinsideoroutsidethepolygon?

• Polygoncollision•  Returnyes/no

• Polygonintersec@on•  Returnpolygonofintersec@on(P)

• Polygonrasteriza@on•  Returnpixelsthat intersect

• Polygonwindingdirec@on•  Returnclockwise(CW)orcounterclockwise(CCW)

Other polygon problems

Moral: easier with simple, convex, low count polygons

Vs

Triangular mesh

Vs

Why triangles …

Whytriangles?1.Easiestpolygontorasterize2.Polygonswithn>3canbenon-planar3.Ligh@ngcomputa@onsin3Dhappenatver@ces-morever@cesgivesmootherillumina@oneffects

Polygon triangulation

Theorem: Every simple polygon has a triangulation

•  Proof by induc-on Base case: n = 3 Induc-ve case A) Pick a convex corner p. Let q and r be pred and succ ver-ces. B) If qr a diagonal, add it. By induc-on, the smaller polygon has a triangula-on. C) If qr not a diagonal, let z be the reflex vertex farthest to qr inside △pqr. D) Add diagonal pz; subpolygons on both sides have triangula-ons.

• Parametriccurves1.  Modelobjectsbyequa@on2.  Complexshapesfromfewvalues3.  Modelingarbitraryshapecanbehard

• Polylines1.  Modelobjectsbydatapoints2.  Complexshapesneedaddi@onaldata3.  Canmodelanyshapeapproximately

•  Lookingforward•  Usepolylinestocontrolgeneralparametriccurves•  B-splines,NURBS

Parametric curves vs. polylines

1.  Defini@onsofpolylineandpolygons2.  Polylinesandpolygonsaspiecewise

discreteapproxima@onstosmoothcurves3.  Defini@onsofproper@esofpolygons

(simple/non-simple,concave/convex)4.  Defini@onofpoint-in-polygonproblemand

crossingsolu@on5.  Trianglesaregood(simplestpolygon,

alwaysplanar,easytorasterize,moreisgood)

6.  Defini@onofpolygontriangula@on(don’tneedtoknowthetheoremyet)

What you should know after today