1 / 11

PMC and Booleans

PMC and Booleans. Point-Membership Classification Regularized Booleans between polygons. 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).

Download Presentation

PMC and Booleans

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

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. P E1 E2 o o o E5 E4 E3 o o o 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 Assume no pixel lies on boundary of any triangle

  5. P E1 E1 E2 o o o o E5 E4 E3 E3 o o o o 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 Ray from Q O 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

More Related