# 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 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(region)[source]

Uniform distribution over points in a Region

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

Abstract class for regions.

intersect(other, triedReversed=False)[source]

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

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]

Region consisting of all space.

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

Region containing no points.

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

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

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

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

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

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]

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