scenic.core.regions

Objects representing regions in space.

Summary of Module Members

Functions

regionFromShapelyObject

Build a ‘Region’ from Shapely geometry.

toPolygon

Classes

AllRegion

Region consisting of all space.

CircularRegion

DifferenceRegion

EmptyRegion

Region containing no points.

GridRegion

A Region given by an obstacle grid.

IntersectionRegion

PointInRegionDistribution

Uniform distribution over points in a Region

PointSetRegion

Region consisting of a set of discrete points.

PolygonalRegion

Region given by one or more polygons (possibly with holes)

PolylineRegion

Region given by one or more polylines (chain of line segments)

RectangularRegion

Region

Abstract class for regions.

SectorRegion

Member Details

regionFromShapelyObject(obj, orientation=None)[source]

Build a ‘Region’ from Shapely geometry.

class PointInRegionDistribution(*args, **kwargs)[source]

Bases: scenic.core.vectors.VectorDistribution

Uniform distribution over points in a Region

class Region(name, *dependencies, orientation=None)[source]

Bases: scenic.core.distributions.Samplable

Abstract class for regions.

intersect(other, triedReversed=False)[source]

Get a Region representing the intersection of this one with another.

intersects(other)[source]

Check if this Region intersects another.

difference(other)[source]

Get a Region representing the difference of this one and another.

union(other, triedReversed=False)[source]

Get a Region representing the union of this one with another.

Not supported by all region types.

static uniformPointIn(region)[source]

Get a uniform Distribution over points in a Region.

uniformPoint()[source]

Sample a uniformly-random point in this Region.

Can only be called on fixed Regions with no random parameters.

uniformPointInner()[source]

Do the actual random sampling. Implemented by subclasses.

containsPoint(point)[source]

Check if the Region contains a point. Implemented by subclasses.

containsObject(obj)[source]

Check if the Region contains an Object.

The default implementation assumes the Region is convex; subclasses must override the method if this is not the case.

getAABB()[source]

Axis-aligned bounding box for this Region. Implemented by some subclasses.

orient(vec)[source]

Orient the given vector along the region’s orientation, if any.

class AllRegion(name, *dependencies, orientation=None)[source]

Bases: scenic.core.regions.Region

Region consisting of all space.

class EmptyRegion(name, *dependencies, orientation=None)[source]

Bases: scenic.core.regions.Region

Region containing no points.

class PolylineRegion(points=None, polyline=None, orientation=True, name=None)[source]

Bases: scenic.core.regions.Region

Region given by one or more polylines (chain of line segments)

signedDistanceTo(point)[source]

Compute the signed distance of the PolylineRegion to a point.

The distance is positive if the point is left of the nearest segment, and negative otherwise.

class PolygonalRegion(points=None, polygon=None, orientation=None, name=None)[source]

Bases: scenic.core.regions.Region

Region given by one or more polygons (possibly with holes)

class PointSetRegion(name, points, kdTree=None, orientation=None, tolerance=1e-06)[source]

Bases: scenic.core.regions.Region

Region consisting of a set of discrete points.

No Object can be contained in a PointSetRegion, since the latter is discrete. (This may not be true for subclasses, e.g. GridRegion.)

Parameters
  • name (str) – name for debugging

  • points (iterable) – set of points comprising the region

  • kdtree (scipy.spatial.KDTree, optional) – k-D tree for the points (one will be computed if none is provided)

  • orientation (VectorField, optional) – orientation for the region

  • tolerance (float; optional) – distance tolerance for checking whether a point lies in the region

class GridRegion(name, grid, Ax, Ay, Bx, By, orientation=None)[source]

Bases: scenic.core.regions.PointSetRegion

A Region given by an obstacle grid.

A point is considered to be in a GridRegion if the nearest grid point is not an obstacle.

Parameters
  • name (str) – name for debugging

  • grid – 2D list, tuple, or NumPy array of 0s and 1s, where 1 indicates an obstacle and 0 indicates free space

  • Ax (float) – spacing between grid points along X axis

  • Ay (float) – spacing between grid points along Y axis

  • Bx (float) – X coordinate of leftmost grid column

  • By (float) – Y coordinate of lowest grid row

  • orientation (VectorField, optional) – orientation of region