# `pymunk.autogeometry` Module

class `pymunk.autogeometry.``PolylineSet`

  Bases: `collections.abc.Sequence`

  A set of Polylines.

  Mainly intended to be used for its `collect_segment()` function when generating geometry with the `march_soft()` and `march_hard()` functions.

  `__init__`()
  `collect_segment`(v0, v1)

    Add a line segment to a polyline set.

    A segment will either start a new polyline, join two others, or add to or loop an existing polyline. This is mostly intended to be used as a callback directly from `march_soft()` or `march_hard()`.

    Parameters: | v0 ((float,float)) – Start of segment v1 ((float,float)) – End of segment

  `count`(value) → integer -- return number of occurrences of value
  `index`(value) → integer -- return first index of value.

    Raises ValueError if the value is not present.

`pymunk.autogeometry.``convex_decomposition`(polyline, tolerance)

  Get an approximate convex decomposition from a polyline.

  Returns a list of convex hulls that match the original shape to within tolerance.

  Note

  If the input is a self intersecting polygon, the output might end up overly simplified.

  Parameters: | polyline ([(float,float)]) – Polyline to simplify. tolerance (float) – A higher value means more error is tolerated.
  Return type: | [(float,float)]

`pymunk.autogeometry.``is_closed`(polyline)

  Returns true if the first vertex is equal to the last.

  Parameters: | polyline ([(float,float)]) – Polyline to simplify.
  Return type: | bool

`pymunk.autogeometry.``march_hard`(bb, x_samples, y_samples, threshold, segment_func, sample_func)

  Trace an aliased curve of an image along a particular threshold.

  The given number of samples will be taken and spread across the bounding box area using the sampling function and context.

  Parameters: | bb (BB) – Bounding box of the area to sample within x_samples (int) – Number of samples in x y_samples (int) – Number of samples in y threshold (float) – A higher value means more error is tolerated segment_func (`func(v0 : Vec2d, v1 : Vec2d)`) – The segment function will be called for each segment detected that lies along the density contour for threshold. sample_func (`func(point: Vec2d) -> float`) – The sample function will be called for x_samples * y_samples spread across the bounding box area, and should return a float.

`pymunk.autogeometry.``march_soft`(bb, x_samples, y_samples, threshold, segment_func, sample_func)

  Trace an anti-aliased contour of an image along a particular threshold.

  The given number of samples will be taken and spread across the bounding box area using the sampling function and context.

  Parameters: | bb (BB) – Bounding box of the area to sample within x_samples (int) – Number of samples in x y_samples (int) – Number of samples in y threshold (float) – A higher value means more error is tolerated segment_func (`func(v0 : Vec2d, v1 : Vec2d)`) – The segment function will be called for each segment detected that lies along the density contour for threshold. sample_func (`func(point: Vec2d) -> float`) – The sample function will be called for x_samples * y_samples spread across the bounding box area, and should return a float.

`pymunk.autogeometry.``simplify_curves`(polyline, tolerance)

  Returns a copy of a polyline simplified by using the Douglas-Peucker algorithm.

  This works very well on smooth or gently curved shapes, but not well on straight edged or angular shapes.

  Parameters: | polyline ([(float,float)]) – Polyline to simplify. tolerance (float) – A higher value means more error is tolerated.
  Return type: | [(float,float)]

`pymunk.autogeometry.``simplify_vertexes`(polyline, tolerance)

  Returns a copy of a polyline simplified by discarding “flat” vertexes.

  This works well on straigt edged or angular shapes, not as well on smooth shapes.

  Parameters: | polyline ([(float,float)]) – Polyline to simplify. tolerance (float) – A higher value means more error is tolerated.
  Return type: | [(float,float)]

`pymunk.autogeometry.``to_convex_hull`(polyline, tolerance)

  Get the convex hull of a polyline as a looped polyline.

  Parameters: | polyline ([(float,float)]) – Polyline to simplify. tolerance (float) – A higher value means more error is tolerated.
  Return type: | [(float,float)]