jakke-graphics-ts
    Preparing search index...

    Function isPointInArea2d

    • Determines whether a given 2D point lies inside, outside, or on the boundary of a closed polyline.

      The function performs several checks:

      1. Verifies if the polyline is closed within a specified tolerance.
      2. Checks if the point lies exactly on any edge or vertex of the polyline.
      3. Quickly rejects points outside the polyline's bounding box (with tolerance).
      4. Uses the ray casting (even/odd rule) algorithm to determine if the point is inside the polyline.
      5. Optionally computes intersection points of a horizontal ray from the point with the polyline.

      Returns a result object containing:

      • result: true if the point is inside or on the boundary, false otherwise.
      • intersections: Array of intersection points (if computed).
      • Flags indicating if the polyline is open, the point is out of bounding box, or on the boundary.

      Parameters

      • polyline: Polyline2d

        The closed polyline represented as an array of 2D vertices.

      • pt: Vertex2d

        The 2D point to test.

      Returns PointInAreaResult

      An object describing the point's relation to the polyline and intersection details.