scenic.core.vectors

Scenic vectors and vector fields.

Summary of Module Members

Functions

makeVectorOperatorHandler

scalarOperator

Decorator for vector operators that yield scalars.

vectorDistributionMethod

Decorator for methods that produce vectors.

vectorOperator

Decorator for vector operators that yield vectors.

Classes

CustomVectorDistribution

Distribution with a custom sampler given by an arbitrary function.

OrientedVector

PiecewiseVectorField

A vector field defined by patching together several regions.

PolygonalVectorField

A piecewise-constant vector field defined over polygonal cells.

Vector

A 2D vector, whose coordinates can be distributions.

VectorDistribution

A distribution over Vectors.

VectorField

A vector field, providing a heading at every point.

VectorMethodDistribution

Vector version of MethodDistribution.

VectorOperatorDistribution

Vector version of OperatorDistribution.

Member Details

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

Bases: scenic.core.distributions.Distribution

A distribution over Vectors.

defaultValueType

alias of scenic.core.vectors.Vector

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

Bases: scenic.core.vectors.VectorDistribution

Distribution with a custom sampler given by an arbitrary function.

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

Bases: scenic.core.vectors.VectorDistribution

Vector version of OperatorDistribution.

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

Bases: scenic.core.vectors.VectorDistribution

Vector version of MethodDistribution.

scalarOperator(method)[source]

Decorator for vector operators that yield scalars.

vectorOperator(method)[source]

Decorator for vector operators that yield vectors.

vectorDistributionMethod(method)[source]

Decorator for methods that produce vectors. See distributionMethod.

class Vector(x, y)[source]

Bases: scenic.core.distributions.Samplable, collections.abc.Sequence

A 2D vector, whose coordinates can be distributions.

rotatedBy(angle)[source]

Return a vector equal to this one rotated counterclockwise by the given angle.

Return type

scenic.core.vectors.Vector

angleWith(other)[source]

Compute the signed angle between self and other.

The angle is positive if other is counterclockwise of self (considering the smallest possible rotation to align them).

Return type

float

class VectorField(name, value, minSteps=4, defaultStepSize=5)[source]

A vector field, providing a heading 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.

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
  • pos (Vector) – point to start from.

  • dist (float) – distance to travel.

  • steps (int) – number of steps to take, or None to compute the number of steps based on the distance (default None).

  • stepSize (float) – length used to compute how many steps to take, or None to use the field’s default step size.

static forUnionOf(regions)[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: scenic.core.vectors.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, defaultHeading=None)[source]

Bases: scenic.core.vectors.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, 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.

  • defaultHeading (float) – the heading for points not in any region with an orientation (default None, meaning reject such points).