scenic.core.geometry

Utility functions for geometric computation.

Summary of Module Members

Functions

addVectors

apparentHeadingAtPoint

averageVectors

circumcircleOfAnnulus

cleanChain

cleanPolygon

cos

findMinMax

headingOfSegment

hypot

max

min

normalizeAngle

plotPolygon

pointIsInCone

polygonUnion

positionRelativeToPoint

radialToCartesian

rotateVector

sin

subtractVectors

triangulatePolygon

Triangulate the given Shapely polygon.

triangulatePolygon_gpc

triangulatePolygon_pypoly2tri

viewAngleToPoint

Classes

RotatedRectangle

mixin providing collision detection for rectangular objects and regions

Exceptions

TriangulationError

Signals that the installed triangulation libraries are insufficient.

Member Details

givePP2TWarning = True

Whether to warn when falling back to pypoly2tri for triangulation

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 currently use the GPC library (wrapped by the Polygon3 package) if it is installed. Since it is not free for commercial use, we don’t require it as a dependency, falling back on the BSD-compatible pypoly2tri as needed. In this case we issue a warning, since GPC is more robust and handles large polygons. The warning can be disabled by setting givePP2TWarning to False.

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]

Bases: object

mixin providing collision detection for rectangular objects and regions

static edgeSeparates(rectA, rectB)[source]

Whether an edge of rectA separates it from rectB