Presentation is loading. Please wait.

Presentation is loading. Please wait.

PMC and Booleans Point-Membership Classification

Similar presentations


Presentation on theme: "PMC and Booleans Point-Membership Classification"— Presentation transcript:

1 PMC and Booleans Point-Membership Classification
Regularized Booleans between polygons

2 Point-in-polygon test in 2D
Given a polygon P and a point q in the plane of P, how would you test whether q lies inside P? This is called “Point-Membership Classification” (abbreviated PMC)

3 Triangle-based point-in-polygon test
Algorithm for testing whether point Q is inside polygon P Boolean PinPoly(Q,P) { pt O = origin or some arbitrary point; Boolean in:= false; for (each edge (A,B) of P) if (PinT(O,A,B,Q)) in := ! in; return in; } boolean PinT(A,B,C,P) {return (right(A,B,P)== right(B,C,P)) && (right(A,B,P)== right(C,A,P)) ;} Why does it work?

4 XOR shading of a polygon in 2D
AB is the set of points that lie in A or in B, but not in both AB := {p: pA  pB } Let A, B, C … N be primitives, then ABC… N is the set of points contained in an odd number of these primitives AB := {p: (pA) XOR (pB) XOR (pC) XOR … XOR (pN) } How to shade a polygon A in 2D: Polygon P has edges Ei. Triangle Ti = convex hull of O+Ei. P = T1T2T3… Tn To fill P: fill each Ti while toggling status of visited pixel o E5 o E4 o E3 E2 o o E1 o P Assume no pixel lies on boundary of any triangle

5 Example of XOR polygon filling

6 Relation to ray-casting approach?
A point Q lies in a set P if a ray from Q intersects the boundary of P an odd number of times If ray hits a vertex or edge or is tangent to a surface, pick another ray We do the same thing. Look at an example in 2D. Here: Only edges E1, E2, E3 intersect ray from Q to O Thus only triangles T1, T2, T3 contain Q Q O Ray from Q Q is in because it is contained in an odd number of triangles

7 Computing polygon area
Two methods: Sum of signed areas of triangles, each joining an arbitrary origin o to a different edge(a,b) SUM oaR(ob) for each edge (a,b) Sum of signed areas between each oriented edge the x-axis y by b ay a x ax bx area(a,b):=(ay+by)(bx–ax)/2

8 Area of the symmetric difference
The symmetric difference AB measures the discrepancy between the two solids A and B It is 0 when A==B Assume that A and B are bounded by consistently oriented polygonal loops. Can I compute AB by summing areas of triangles?

9 Boolean operation on polygons
Diminishing boundary principle: The Boundary of a Boolean combination of shapes is a subset of the union of their boundaries Strategy: Generate-Split-Select Generate a sufficient set of candidates: edges of polygons Split them at their pairwise intersections Select the edge-segments on the boundary of the result How to identify a good edge segment? Must separate in from out t s

10 Boolean A–B (also written A \ B) A A B B

11 Regularization AB ? B A


Download ppt "PMC and Booleans Point-Membership Classification"

Similar presentations


Ads by Google