gnome.utilities.geometry.PinP

Point in Polygon code.

Module Contents

Functions

points_in_poly(pgon, points)

compute whether the points given are in the polygon defined in pgon.

CrossingsTest(pgon, xxx_todo_changeme)

Point in polygon test using the "Crossings" algorithm.

gnome.utilities.geometry.PinP.points_in_poly(pgon, points)

compute whether the points given are in the polygon defined in pgon.

Parameters:
  • pgon (NX2 numpy array of floats) – the vertices of teh polygon

  • points (NX3 numpy array of (x, y, z) floats) – the points to test

Returns:

a boolean array the same length as points

Note: this version takes a 3-d point, even though the third coord is ignored.

gnome.utilities.geometry.PinP.CrossingsTest(pgon, xxx_todo_changeme)

Point in polygon test using the “Crossings” algorithm.

CrossingsTest(pgon, (tx, ty))

pgon is an NX2 numpy array of points (or something that can be turned into one)

(tx, ty) is the coords of the point to check

translated from C code from “Graphics Gems”

This could be compiled with cython nicely

Note: This code will ignore the last point if the first and last points

are the same.