CrossingCount

CrossingCount[contour,p]

gives a count of the number of times a ray starting from the point p crosses the closed curve contour.

Details

  • CrossingCount is also known as crossing number.
  • CrossingCount is typically used to determine the inclusion of a point in a polygon.
  • If the closed curve contour is selfintersecting, CrossingCount[contour,p] gives the minimal count among all rays starting from the point p.
  • The closed curve contour is typically a collection of line segments Line[{{p1,p2},,{pn-1,pn},{pn,p1}}] and must lie in a plane.

Examples

open allclose all

Basic Examples  (1)

Count how many times a ray starting from the point crosses the closed-curve contour:

Scope  (3)

Count how many times a ray starting from the point crosses the closed-curve contour:

Polygon boundary curves:

Polygons with GeoGridPosition:

Applications  (1)

Color points based on the crossing count of a point in the given polygon:

Properties & Relations  (1)

WindingCount is an alternate count function:

Introduced in 2019
 (12.0)