scenic.core.vectors
Scenic vectors and vector fields.
Summary of Module Members
Functions
Whether this orientation is always aligned with the global coordinate system. |
|
|
|
Decorator for vector operators that yield scalars. |
|
Decorator for methods that produce vectors. |
|
Decorator for vector operators that yield vectors. |
|
|
|
|
Classes
An orientation in 3D space. |
|
|
|
A vector field defined by patching together several regions. |
|
A piecewise-constant vector field defined over polygonal cells. |
|
|
|
A 3D vector, whose coordinates can be distributions. |
|
A distribution over Vectors. |
|
A vector field, providing an orientation at every point. |
|
Vector version of MethodDistribution. |
|
Vector version of OperatorDistribution. |
Member Details
- class VectorDistribution(*dependencies, valueType=None)[source]
Bases:
Distribution
A distribution over Vectors.
- class VectorOperatorDistribution(operator, obj, operands)[source]
Bases:
VectorDistribution
Vector version of OperatorDistribution.
- class VectorMethodDistribution(method, obj, args, kwargs)[source]
Bases:
VectorDistribution
Vector version of MethodDistribution.
- vectorOperator(method, preservesZero=False, zeroIdentity=False)[source]
Decorator for vector operators that yield vectors.
- vectorDistributionMethod(method)[source]
Decorator for methods that produce vectors. See distributionMethod.
- class Orientation(rotation)[source]
An orientation in 3D space.
- classmethod fromQuaternion(quaternion)[source]
Create an
Orientation
from a quaternion (of the form (x,y,z,w))- Return type:
- classmethod fromEuler(yaw, pitch, roll)[source]
Create an
Orientation
from yaw, pitch, and roll angles (in radians).- Return type:
- alwaysGlobalOrientation(orientation)[source]
Whether this orientation is always aligned with the global coordinate system.
Returns False if the orientation is a distribution or delayed argument, since then the value cannot be known at this time.
- class Vector(x, y, z=0)[source]
-
A 3D vector, whose coordinates can be distributions.
- class VectorField(name, value, minSteps=4, defaultStepSize=5)[source]
A vector field, providing an orientation at every point.
- Parameters:
name (str) – name for debugging.
value – function computing the heading at the given
Vector
.minSteps (int) – Minimum number of steps for
followFrom
; default 4.defaultStepSize (float) – Default step size for
followFrom
; default 5. This is an upper bound: more steps will be taken as needed to ensure that no single step is longer than this value, but if the distance to travel is small then the steps may be smaller.
- followFrom(pos, dist, steps=None, stepSize=None)[source]
Follow the field from a point for a given distance.
Uses the forward Euler approximation, covering the given distance with equal-size steps. The number of steps can be given manually, or computed automatically from a desired step size.
- Parameters:
- static forUnionOf(regions, tolerance=0)[source]
Creates a
PiecewiseVectorField
from the union of the given regions.If none of the regions have an orientation, returns
None
instead.
- class PolygonalVectorField(name, cells, headingFunction=None, defaultHeading=None)[source]
Bases:
VectorField
A piecewise-constant vector field defined over polygonal cells.
- Parameters:
name (str) – name for debugging.
cells – a sequence of cells, with each cell being a pair consisting of a Shapely geometry and a heading. If the heading is
None
, we call the given headingFunction for points in the cell instead.headingFunction – function computing the heading for points in cells without specified headings, if any (default
None
).defaultHeading – heading for points not contained in any cell (default
None
, meaning reject such points).
- class PiecewiseVectorField(name, regions, tolerance=0, defaultHeading=None)[source]
Bases:
VectorField
A vector field defined by patching together several regions.
The heading at a point is determined by checking each region in turn to see if it has an orientation and contains the point, returning the corresponding heading if so. If we get through all the regions, and tolerance is nonzero, we try again, this time allowing the point to be up to tolerance away from each region. If we still fail to find a region “containing” the point, then we return the defaultHeading, if any, and otherwise reject the scene.
- Parameters:
name (str) – name for debugging.
regions (sequence of
Region
objects) – the regions making up the field.tolerance (float) – maximum distance at which to consider a point as being in one of the regions, if it is not otherwise contained (default 0).
defaultHeading (float) – the heading for points not in any region with an orientation (default
None
, meaning reject such points).