semantic_world.geometry#

Attributes#

Classes#

Color

Dataclass for storing rgba_color as an RGBA value.

Scale

Dataclass for storing the scale of geometric objects.

Shape

Base class for all shapes in the world.

Mesh

A mesh shape.

Primitive

A primitive shape.

Sphere

A sphere shape.

Cylinder

A cylinder shape.

Box

A box shape. Pivot point is at the center of the box.

BoundingBox

BoundingBoxCollection

Dataclass for storing a collection of bounding boxes.

Module Contents#

semantic_world.geometry.id_generator#
class semantic_world.geometry.Color#

Dataclass for storing rgba_color as an RGBA value. The values are stored as floats between 0 and 1. The default rgba_color is white.

R: float = 1#

Red value of the color.

G: float = 1#

Green value of the color.

B: float = 1#

Blue value of the color.

A: float = 1#

Opacity of the color.

class semantic_world.geometry.Scale#

Dataclass for storing the scale of geometric objects.

x: float = 1.0#

The scale in the x direction.

y: float = 1.0#

The scale in the y direction.

z: float = 1.0#

The scale in the z direction.

class semantic_world.geometry.Shape#

Bases: abc.ABC

Base class for all shapes in the world.

origin: semantic_world.spatial_types.TransformationMatrix#
abstract as_bounding_box() BoundingBox#

Returns the bounding box of the shape. This method should be implemented by subclasses.

property mesh: trimesh.Trimesh#
Abstractmethod:

The mesh object of the shape. This should be implemented by subclasses.

class semantic_world.geometry.Mesh#

Bases: Shape

A mesh shape.

filename: str = ''#

Filename of the mesh.

scale: Scale#

Scale of the mesh.

property mesh: trimesh.Trimesh#

The mesh object.

as_bounding_box() BoundingBox#

Returns the bounding box of the mesh.

class semantic_world.geometry.Primitive#

Bases: Shape

A primitive shape.

color: Color#
class semantic_world.geometry.Sphere#

Bases: Primitive

A sphere shape.

radius: float = 0.5#

Radius of the sphere.

property mesh: trimesh.Trimesh#

Returns a trimesh object representing the sphere.

as_bounding_box() BoundingBox#

Returns the bounding box of the sphere.

class semantic_world.geometry.Cylinder#

Bases: Primitive

A cylinder shape.

width: float = 0.5#
height: float = 0.5#
property mesh: trimesh.Trimesh#

Returns a trimesh object representing the cylinder.

as_bounding_box() BoundingBox#

Returns the bounding box of the cylinder. The bounding box is axis-aligned and centered at the origin.

class semantic_world.geometry.Box#

Bases: Primitive

A box shape. Pivot point is at the center of the box.

scale: Scale#
property mesh: trimesh.Trimesh#

Returns a trimesh object representing the box. The box is centered at the origin and has the specified scale.

as_bounding_box() BoundingBox#

Returns the bounding box of the box.

class semantic_world.geometry.BoundingBox#
min_x: float#

The minimum x-coordinate of the bounding box.

min_y: float#

The minimum y-coordinate of the bounding box.

min_z: float#

The minimum z-coordinate of the bounding box.

max_x: float#

The maximum x-coordinate of the bounding box.

max_y: float#

The maximum y-coordinate of the bounding box.

max_z: float#

The maximum z-coordinate of the bounding box.

property x_interval: random_events.interval.SimpleInterval#
Returns:

The x interval of the bounding box.

property y_interval: random_events.interval.SimpleInterval#
Returns:

The y interval of the bounding box.

property z_interval: random_events.interval.SimpleInterval#
Returns:

The z interval of the bounding box.

property depth: float#
property height: float#
property width: float#
property simple_event: random_events.product_algebra.SimpleEvent#
Returns:

The bounding box as a random event.

bloat(x_amount: float = 0.0, y_amount: float = 0, z_amount: float = 0) BoundingBox#

Enlarges the bounding box by a given amount in all dimensions.

Parameters:
  • x_amount – The amount to adjust minimum and maximum x-coordinates

  • y_amount – The amount to adjust minimum and maximum y-coordinates

  • z_amount – The amount to adjust minimum and maximum z-coordinates

Returns:

New enlarged bounding box

contains(point: semantic_world.spatial_types.Point3) bool#

Check if the bounding box contains a point.

as_collection() BoundingBoxCollection#

Convert the bounding box to a collection of bounding boxes.

Returns:

The bounding box as a collection

classmethod from_simple_event(simple_event: random_events.product_algebra.SimpleEvent)#

Create a list of bounding boxes from a simple random event.

Parameters:

simple_event – The random event.

Returns:

The list of bounding boxes.

intersection_with(other: BoundingBox) BoundingBox | None#

Compute the intersection of two bounding boxes.

Parameters:

other – The other bounding box.

Returns:

The intersection of the two bounding boxes or None if they do not intersect.

enlarge(min_x: float = 0.0, min_y: float = 0, min_z: float = 0, max_x: float = 0.0, max_y: float = 0.0, max_z: float = 0.0)#

Enlarge the axis-aligned bounding box by a given amount in-place. :param min_x: The amount to enlarge the minimum x-coordinate :param min_y: The amount to enlarge the minimum y-coordinate :param min_z: The amount to enlarge the minimum z-coordinate :param max_x: The amount to enlarge the maximum x-coordinate :param max_y: The amount to enlarge the maximum y-coordinate :param max_z: The amount to enlarge the maximum z-coordinate

enlarge_all(amount: float)#

Enlarge the axis-aligned bounding box in all dimensions by a given amount in-place.

Parameters:

amount – The amount to enlarge the bounding box

classmethod from_mesh(mesh: trimesh.Trimesh) typing_extensions.Self#

Create a bounding box from a trimesh object. :param mesh: The trimesh object. :return: The bounding box.

get_points() List[semantic_world.spatial_types.Point3]#

Get the 8 corners of the bounding box as Point3 objects.

Returns:

A list of Point3 objects representing the corners of the bounding box.

classmethod from_min_max(min_point: semantic_world.spatial_types.Point3, max_point: semantic_world.spatial_types.Point3) typing_extensions.Self#

Set the axis-aligned bounding box from a minimum and maximum point.

Parameters:
  • min_point – The minimum point

  • max_point – The maximum point

class semantic_world.geometry.BoundingBoxCollection#

Dataclass for storing a collection of bounding boxes.

bounding_boxes: List[BoundingBox] = []#
property event: random_events.product_algebra.Event#
Returns:

The bounding boxes as a random event.

merge(other: BoundingBoxCollection) BoundingBoxCollection#

Merge another bounding box collection into this one.

Parameters:

other – The other bounding box collection.

Returns:

The merged bounding box collection.

bloat(x_amount: float = 0.0, y_amount: float = 0, z_amount: float = 0) BoundingBoxCollection#

Enlarges all bounding boxes in the collection by a given amount in all dimensions.

Parameters:
  • x_amount – The amount to adjust the x-coordinates

  • y_amount – The amount to adjust the y-coordinates

  • z_amount – The amount to adjust the z-coordinates

Returns:

The enlarged bounding box collection

classmethod from_simple_event(simple_event: random_events.product_algebra.SimpleEvent)#

Create a list of bounding boxes from a simple random event.

Parameters:

simple_event – The random event.

Returns:

The list of bounding boxes.

classmethod from_event(event: random_events.product_algebra.Event) typing_extensions.Self#

Create a list of bounding boxes from a random event.

Parameters:

event – The random event.

Returns:

The list of bounding boxes.

classmethod from_shapes(shapes: List[Shape]) typing_extensions.Self#

Create a bounding box collection from a list of shapes.

Parameters:

shapes – The list of shapes.

Returns:

The bounding box collection.