scenic.core.regions¶
Objects representing regions in space.
Manipulations of polygons and line segments are done using the shapely package.
Summary of Module Members¶
Module Attributes
A 

A 
Functions
Build a 


Classes
Region consisting of all space. 

A circular region with a possiblyrandom center and radius. 



Region containing no points. 

A Region given by an obstacle grid. 



Uniform distribution over points in a Region. 

Region consisting of a set of discrete points. 

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

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

A rectangular region with a possiblyrandom position, heading, and size. 

Abstract class for regions. 

A sector of a 
Member Details¶
 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)[source]¶
Get a
Region
representing the intersection of this one with another. Return type
 difference(other)[source]¶
Get a
Region
representing the difference of this one and another. Return type
 union(other)[source]¶
Get a
Region
representing the union of this one with another.Not supported by all region types.
 Return type
 static uniformPointIn(region)[source]¶
Get a uniform
Distribution
over points in aRegion
.
 uniformPoint()[source]¶
Sample a uniformlyrandom point in this
Region
.Can only be called on fixed Regions with no random parameters.
 containsPoint(point)[source]¶
Check if the
Region
contains a point. Implemented by subclasses. Return type
 containsObject(obj)[source]¶
Check if the
Region
contains anObject
.The default implementation assumes the
Region
is convex; subclasses must override the method if this is not the case. Return type
 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.
 everywhere = <AllRegion everywhere>¶
A
Region
containing all points.Points may not be sampled from this region, as no uniform distribution over it exists.
 nowhere = <EmptyRegion nowhere>¶
A
Region
containing no points.Attempting to sample from this region causes the sample to be rejected.
 class CircularRegion(center, radius, resolution=32, name=None)[source]¶
Bases:
scenic.core.regions.Region
A circular region with a possiblyrandom center and radius.
 class SectorRegion(center, radius, heading, angle, resolution=32, name=None)[source]¶
Bases:
scenic.core.regions.Region
A sector of a
CircularRegion
.This region consists of a sector of a disc, i.e. the part of a disc subtended by a given arc.
 Parameters
center (
Vector
) – center of the corresponding disc.radius (float) – radius of the disc.
heading (float) – heading of the centerline of the sector.
angle (float) – angle subtended by the sector.
resolution (int; optional) – number of vertices to use when approximating this region as a polygon.
name (str; optional) – name for debugging.
 class RectangularRegion(position, heading, width, length, name=None)[source]¶
Bases:
scenic.core.regions.Region
A rectangular region with a possiblyrandom position, heading, and size.
 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).
The region may be specified by giving either a sequence of points or
shapely
polylines (aLineString
orMultiLineString
). Parameters
points – sequence of points making up the polyline (or
None
if using the polyline argument instead).polyline –
shapely
polyline or collection of polylines (orNone
if using the points argument instead).orientation (optional) – preferred orientation to use, or
True
to use an orientation aligned with the direction of the polyline (the default).name (str; optional) – name for debugging.
 property start¶
Get an
OrientedPoint
at the start of the polyline.The OP’s heading will be aligned with the orientation of the region, if there is one (the default orientation pointing along the polyline).
 property end¶
Get an
OrientedPoint
at the end of the polyline.The OP’s heading will be aligned with the orientation of the region, if there is one (the default orientation pointing along the polyline).
 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.
 Return type
 pointAlongBy(distance, normalized=False)[source]¶
Find the point a given distance along the polyline from its start.
If normalized is true, then distance should be between 0 and 1, and is interpreted as a fraction of the length of the polyline. So for example
pointAlongBy(0.5, normalized=True)
returns the polyline’s midpoint. Return type
 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).
The region may be specified by giving either a sequence of points defining the boundary of the polygon, or a collection of
shapely
polygons (aPolygon
orMultiPolygon
). Parameters
points – sequence of points making up the boundary of the polygon (or
None
if using the polygon argument instead).polygon –
shapely
polygon or collection of polygons (orNone
if using the points argument instead).orientation (
VectorField
; optional) – preferred orientation to use.name (str; optional) – name for debugging.
 property boundary: scenic.core.regions.PolylineRegion¶
Get the boundary of this region as a
PolylineRegion
.
 class PointSetRegion(name, points, kdTree=None, orientation=None, tolerance=1e06)[source]¶
Bases:
scenic.core.regions.Region
Region consisting of a set of discrete points.
No
Object
can be contained in aPointSetRegion
, 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) – kD tree for the points (one will be computed if none is provided)orientation (
VectorField
; optional) – preferred orientation for the regiontolerance (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