cartagen.hull_swinging_arm

cartagen.hull_swinging_arm#

hull_swinging_arm(points, length, direction='ccw')#

Create the hull of a set of points using the swinging arm algorithm.

This algorithm is described in Galton & Duckham. [1] Starting at the most northen point, iteratively create the border of a polygon by adding the first point intersecting the line (the arm) rotating around the point.

Parameters:
  • points (list of Point) – The set of points.

  • length (int) – The length of the line (or arm) that will rotate around the point.

  • direction (str, optional) – The direction of the arm’s rotation. Can be ‘ccw’ or ‘cw’.

Returns:

list of Polygon

See also

hull_delaunay

Create the hull of a set of points using the Delaunay triangulation.

Notes

This algorithm can create multiple polygons, unlike hull_delaunay()

References

Examples

>>> points = [ Point(1, 1), Point(6, 6), Point(1, 6), Point(6, 5), Point(2, 4), Point(2, 1), Point(1, 4) ]
>>> swinging_arm(points, 5.0)
[<POLYGON ((1 4, 1 1, 2 1, 2 4, 1 4))>]

(Source code)

../_images/hull_swinging_arm.png