XYParitySearchContext Class

XYParitySearchContext is an internal class for callers that can feed points (without extracting to array structures)

  • Most will be via static methods which handle a specific data source.
    • PolygonOps.classifyPointInPolygon(x,y,points: XAndY[])
    • HalfEdgeGraphSearch.pointInOrOnFaceXY(halfEdgeOnFace, x, y) Use pattern:
  • Caller must be able to walk around polygon producing x,y coordinates (possibly transformed from actual polygon).
  • Caller announce edges to tryStartEdge until finding one acceptable to the search.
  • Caller then passes additional points up to and including both x0,y0 and x1, y1 of the accepted start edge. Call sequence is:
    • context = new XYParitySearchContext
    • repeat { acquire edge (x0,y0) (x1,y1) } until context.tryStartEdge(x0,y0,x1,y1);
    • for each (x,y) beginning AFTER x1,y1 and ending with (x1,y1) context.advance (x,y)
    • return context.classifyCounts();

Methods

Name Description
constructor(xTest: number, yTest: number): XYParitySearchContext Create a new searcher for specified test point.  
advance(x2: number, y2: number): boolean Process the current edge ending at (x2,y2).  
classifyCounts(): undefined | number Return classification as ON, IN, or OUT according to hit and crossing counts.  
tryStartEdge(x0: number, y0: number, x1: number, y1: number): boolean Test if parity processing can begin with this edge.  

Properties

Name Type Description
numHit number    
numLeftCrossing number    
numRightCrossing number    
u0 number local x-coordinate of the start of the previous (or earlier) edge  
u1 number local x-coordinate of the end of the previous edge (and start of current edge)  
v0 number local y-coordinate of the start of the previous (or earlier) edge  
v1 number local y-coordinate of the end of the previous edge (and start of current edge)  
xTest number    
yTest number    

Defined in

Last Updated: 14 November, 2024