scenic.core.geometry

Utility functions for geometric computation.

Summary of Module Members

Functions

addVectors

apparentHeadingAtPoint

averageVectors

checkPolygon

circumcircleOfAnnulus

cleanChain

cleanPolygon

cos

distanceToLine

distanceToSegment

findMinMax

headingOfSegment

hypot

max

min

normalizeAngle

plotPolygon

pointIsInCone

polygonUnion

positionRelativeToPoint

radialToCartesian

removeHoles

rotateVector

sin

splitSelfIntersections

subtractVectors

triangulatePolygon

Triangulate the given Shapely polygon.

triangulatePolygon_mapbox

triangulatePolygon_pypoly2tri

viewAngleToPoint

Exceptions

TriangulationError

Signals that the installed triangulation libraries are insufficient.

Member Details

exception TriangulationError[source]

Bases: RuntimeError

Signals that the installed triangulation libraries are insufficient.

Specifically, raised when pypoly2tri hits the recursion limit trying to triangulate a large polygon.

triangulatePolygon(polygon)[source]

Triangulate the given Shapely polygon.

Note that we can’t use shapely.ops.triangulate since it triangulates point sets, not polygons (i.e., it doesn’t respect edges). We need an algorithm for triangulation of polygons with holes (it doesn’t need to be a Delaunay triangulation).

We use mapbox_earcut by default. If it is not installed, we allow fallback to pypoly2tri for historical reasons (we originally used the GPC library, which is not free for commercial use, falling back to pypoly2tri if not installed).

Parameters

polygon (shapely.geometry.Polygon) – Polygon to triangulate.

Returns

A list of disjoint (except for edges) triangles whose union is the original polygon.

class _RotatedRectangle[source]

mixin providing collision detection for rectangular objects and regions