Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
Aleph::PointInPolygonWinding Class Reference

Exact point-in-polygon classification via winding number. More...

#include <geom_algorithms.H>

Public Types

enum class  Location { Outside , Boundary , Inside }
 

Static Public Member Functions

static Location locate (const Polygon &poly, const Point &p)
 Classify point location with respect to a polygon.
 
static bool contains (const Polygon &poly, const Point &p)
 Return true if the point is inside or on the boundary.
 
static bool strictly_contains (const Polygon &poly, const Point &p)
 Return true only for strict interior points.
 

Detailed Description

Exact point-in-polygon classification via winding number.

Classifies a point relative to a simple closed polygon as:

  • Inside
  • Boundary
  • Outside

Uses exact geometric predicates (orientation, on_segment) with Geom_Number, avoiding floating-point robustness issues.

Requirements

  • Polygon must be closed.
  • Polygon must have at least 3 vertices.
  • Polygon should be simple (non-self-intersecting).

Complexity

  • Time: O(n), where n is number of polygon edges.
  • Space: O(1).

Definition at line 1489 of file geom_algorithms.H.

Member Enumeration Documentation

◆ Location

Enumerator
Outside 
Boundary 
Inside 

Definition at line 1492 of file geom_algorithms.H.

Member Function Documentation

◆ contains()

static bool Aleph::PointInPolygonWinding::contains ( const Polygon poly,
const Point p 
)
inlinestatic

Return true if the point is inside or on the boundary.

Parameters
polyClosed simple polygon.
pQuery point.
Returns
true iff location is Inside or Boundary.

Definition at line 1533 of file geom_algorithms.H.

References locate(), and Outside.

Referenced by brute_convex_distance_squared(), demo_advanced_algorithms(), Aleph::ShortestPathInPolygon::operator()(), Aleph::ConvexPolygonDistanceGJK::polygons_intersect_or_contain(), Aleph::detail::shortest_path_portals(), and TEST_F().

◆ locate()

static Location Aleph::PointInPolygonWinding::locate ( const Polygon poly,
const Point p 
)
inlinestatic

Classify point location with respect to a polygon.

Parameters
polyClosed simple polygon.
pQuery point.
Returns
Location::Outside, Location::Boundary, or Location::Inside.
Exceptions
domain_errorif polygon is open or has fewer than 3 vertices.

Definition at line 1508 of file geom_algorithms.H.

References ah_domain_error_if, Boundary, Aleph::Polygon::Boundary, Aleph::divide_and_conquer_partition_dp(), Inside, Aleph::Polygon::Inside, Aleph::Polygon::is_closed(), Aleph::Polygon::locate_point(), Outside, Aleph::Polygon::Outside, and Aleph::Polygon::size().

Referenced by contains(), strictly_contains(), TEST(), and TEST_F().

◆ strictly_contains()

static bool Aleph::PointInPolygonWinding::strictly_contains ( const Polygon poly,
const Point p 
)
inlinestatic

Return true only for strict interior points.

Parameters
polyClosed simple polygon.
pQuery point.
Returns
true iff location is Inside.

Definition at line 1546 of file geom_algorithms.H.

References Inside, and locate().

Referenced by Aleph::VisibilityPolygon::operator()().


The documentation for this class was generated from the following file: