spatialgeometry.Shape
- class Shape(pose: ndarray | SE3 = array([[1., 0., 0., 0.], [0., 1., 0., 0.], [0., 0., 1., 0.], [0., 0., 0., 1.]]), color: list | ndarray | tuple | set | None = None, stype: str | None = None, base: ndarray | SE3 | None = None, **kwargs)[source]
Bases:
SceneNode,ABCAbstract base class for a renderable 3D shape in a scene graph.
It is a
SceneNodeinstance with atributes for its type, shape, and color. Thecollisionattribute is a read-only bool, used for objects that are drawn in the scene but take no part in collision detection (seeCollisionShapefor that).- Parameters:
pose – Local reference frame of the shape, defaults to the identity transform.
color – Color as (r, g, b) or (r, g, b, a) in [0-1] (or [0-255], auto-normalised), or a matplotlib color name. Defaults to a mid-grey
(0.3, 0.3, 0.3, 1.0).stype – Shape type identifier used by the renderer/wire protocol (e.g.
"cuboid","mesh") – set by each concrete subclass, not normally passed directly by a caller.base – Deprecated alias for
pose.
- bounds(world: bool = False) ndarray[source]
Min/max extent of this shape’s axis-aligned bounding box along each axis.
- Parameters:
world – See
corners().- Return type:
ndarray(3,2)
- property collision: bool
True if this shape is used for collision checking rather than (or as well as) visual rendering, as set by the
collisionargument of aCollisionShapesubclass’ constructor.This is a read-only property.
- Return type:
bool
- property color: tuple[float, float, float, float]
shape.color returns a four length tuple representing (red, green, blue, opacity) where opacity represents transparency. Values returned are in the range [0-1]. See
opacityfor a convenient way to get/set just this last channel.
- corners(world: bool = False) ndarray[source]
The 8 corners of this shape’s axis-aligned bounding box.
- Parameters:
world – If True, apply this shape’s current pose and return the axis-aligned envelope of the posed shape (its corners will move as the shape is re-posed, and a rotated shape’s envelope is generally larger than its own local box – this is not the shape’s true oriented/rotated corners). If False (default), return the corners in the shape’s own local frame, independent of pose – constant unless the shape’s own parameters (radius, scale, …) change.
- Return type:
ndarray(3,8)
- extents(world: bool = False) ndarray[source]
Dimensions (width, depth, height) of this shape’s axis-aligned bounding box.
- Parameters:
world – See
corners().- Return type:
ndarray(3,)
- fk_dict() dict[str, Any][source]
fk_dict() outputs shapes pose in dictionary form
- Returns:
The shape pose in translation and quternion form
- Return type:
dict
- property opacity: float
The last channel of
color, in [0-1] – 1.0 is fully opaque, 0.0 fully transparent. A convenience for touching just this channel without needing to know or re-specify the current (r, g, b).Note
“Opacity” here is the same quantity commonly called “alpha” in computer graphics (as in RGBA) – this package uses “opacity” consistently as the public name for it.
This is a read/write property.
- Return type:
float
- abstractmethod to_dict() dict[str, Any][source]
to_dict() returns the shapes information in dictionary form
- Returns:
All information about the shape
- Return type:
dict
- property v: ndarray
Spatial velocity of the shape as a 6-vector: linear velocity
v[:3]followed by angular velocityv[3:6]. Used to integrate the shape’s pose between frames, e.g. bySwift.step()when no per-step callback is supplied.This is a read/write property.
- Return type:
ndarray(6)