ostk.mathematics.geometry.d3.object.Composite¶
- class Composite( )¶
Bases:
Object
Create a composite object from a single geometric object.
- Parameters:
object (Object) -- The geometric object to wrap in the composite.
Example
>>> point = Point(1.0, 2.0, 3.0) >>> composite = Composite(point)
Methods
Access the object at a specific index in the composite.
Apply a transformation to all objects in the composite in place.
Convert the composite to a Composite object.
Convert the composite to a Cone object.
Convert the composite to an Ellipsoid object.
Convert the composite to a Line object.
Convert the composite to a LineString object.
Convert the composite to a Plane object.
Convert the composite to a Point object.
Convert the composite to a PointSet object.
Convert the composite to a Polygon object.
Convert the composite to a Pyramid object.
Convert the composite to a Ray object.
Convert the composite to a Segment object.
Convert the composite to a Sphere object.
Overloaded function.
Create an empty composite (containing no objects).
Get the number of objects contained in the composite.
Overloaded function.
Overloaded function.
Check if the composite contains another Composite object.
Check if the composite contains a Cone object.
Check if the composite is defined.
Check if the composite contains an Ellipsoid object.
Check if the composite is empty (contains no objects).
Check if the composite contains a Line object.
Check if the composite contains a LineString object.
Check if the composite contains a Plane object.
Check if the composite contains a Point object.
Check if the composite contains a PointSet object.
Check if the composite contains a Polygon object.
Check if the composite contains a Pyramid object.
Check if the composite contains a Ray object.
Check if the composite contains a Segment object.
Check if the composite contains a Sphere object.
Create an undefined composite.
- __add__(
- self: ostk.mathematics.geometry.d3.object.Composite,
- arg0: ostk.mathematics.geometry.d3.object.Composite,
- access_object_at(
- self: ostk.mathematics.geometry.d3.object.Composite,
- index: int,
Access the object at a specific index in the composite.
- Parameters:
index (int) -- The index of the object to access.
- Returns:
Reference to the object at the specified index.
- Return type:
- Raises:
IndexError -- If the index is out of bounds.
Example
>>> composite = Composite(Point(1.0, 2.0, 3.0)) >>> obj = composite.access_object_at(0)
- apply_transformation(
- self: ostk.mathematics.geometry.d3.object.Composite,
- transformation: ostk::mathematics::geometry::d3::Transformation,
Apply a transformation to all objects in the composite in place.
- Parameters:
transformation (Transformation) -- The transformation to apply.
Example
>>> composite = Composite(Point(1.0, 2.0, 3.0)) >>> transformation = Translation([1.0, 1.0, 1.0]) >>> composite.apply_transformation(transformation)
- as_composite( ) ostk.mathematics.geometry.d3.object.Composite ¶
Convert the composite to a Composite object.
- Returns:
The composite object contained in the composite.
- Return type:
- Raises:
RuntimeError -- If the composite does not contain a Composite.
Example
>>> inner_composite = Composite(Point(1.0, 2.0, 3.0)) >>> outer_composite = Composite(inner_composite) >>> extracted_composite = outer_composite.as_composite()
- as_cone( ) ostk.mathematics.geometry.d3.object.Cone ¶
Convert the composite to a Cone object.
- Returns:
The cone object contained in the composite.
- Return type:
- Raises:
RuntimeError -- If the composite does not contain a Cone.
Example
>>> cone = Cone(Point(0.0, 0.0, 0.0), numpy.array([0.0, 0.0, 1.0]), Angle.degrees(30.0)) >>> composite = Composite(cone) >>> extracted_cone = composite.as_cone()
- as_ellipsoid( ) ostk.mathematics.geometry.d3.object.Ellipsoid ¶
Convert the composite to an Ellipsoid object.
- Returns:
The ellipsoid object contained in the composite.
- Return type:
- Raises:
RuntimeError -- If the composite does not contain an Ellipsoid.
Example
>>> ellipsoid = Ellipsoid(Point(0.0, 0.0, 0.0), 1.0, 0.8, 0.6) >>> composite = Composite(ellipsoid) >>> extracted_ellipsoid = composite.as_ellipsoid()
- as_line( ) ostk.mathematics.geometry.d3.object.Line ¶
Convert the composite to a Line object.
- Returns:
The line object contained in the composite.
- Return type:
- Raises:
RuntimeError -- If the composite does not contain a Line.
Example
>>> line = Line(Point(0.0, 0.0, 0.0), numpy.array([1.0, 0.0, 0.0])) >>> composite = Composite(line) >>> extracted_line = composite.as_line()
- as_line_string( ) ostk.mathematics.geometry.d3.object.LineString ¶
Convert the composite to a LineString object.
- Returns:
The line string object contained in the composite.
- Return type:
- Raises:
RuntimeError -- If the composite does not contain a LineString.
Example
>>> points = [Point(0.0, 0.0, 0.0), Point(1.0, 1.0, 1.0), Point(2.0, 2.0, 2.0)] >>> line_string = LineString(points) >>> composite = Composite(line_string) >>> extracted_line_string = composite.as_line_string()
- as_plane( ) ostk.mathematics.geometry.d3.object.Plane ¶
Convert the composite to a Plane object.
- Returns:
The plane object contained in the composite.
- Return type:
- Raises:
RuntimeError -- If the composite does not contain a Plane.
Example
>>> plane = Plane(Point(0.0, 0.0, 0.0), numpy.array([0.0, 0.0, 1.0])) >>> composite = Composite(plane) >>> extracted_plane = composite.as_plane()
- as_point( ) ostk.mathematics.geometry.d3.object.Point ¶
Convert the composite to a Point object.
- Returns:
The point object contained in the composite.
- Return type:
- Raises:
RuntimeError -- If the composite does not contain a Point.
Example
>>> composite = Composite(Point(1.0, 2.0, 3.0)) >>> point = composite.as_point()
- as_point_set( ) ostk.mathematics.geometry.d3.object.PointSet ¶
Convert the composite to a PointSet object.
- Returns:
The point set object contained in the composite.
- Return type:
- Raises:
RuntimeError -- If the composite does not contain a PointSet.
Example
>>> point_set = PointSet([Point(1.0, 2.0, 3.0), Point(4.0, 5.0, 6.0)]) >>> composite = Composite(point_set) >>> extracted_set = composite.as_point_set()
- as_polygon( ) ostk.mathematics.geometry.d3.object.Polygon ¶
Convert the composite to a Polygon object.
- Returns:
The polygon object contained in the composite.
- Return type:
- Raises:
RuntimeError -- If the composite does not contain a Polygon.
Example
>>> vertices = [Point(0.0, 0.0, 0.0), Point(1.0, 0.0, 0.0), Point(1.0, 1.0, 0.0)] >>> polygon = Polygon(vertices) >>> composite = Composite(polygon) >>> extracted_polygon = composite.as_polygon()
- as_pyramid( ) ostk.mathematics.geometry.d3.object.Pyramid ¶
Convert the composite to a Pyramid object.
- Returns:
The pyramid object contained in the composite.
- Return type:
- Raises:
RuntimeError -- If the composite does not contain a Pyramid.
Example
>>> apex = Point(0.0, 0.0, 1.0) >>> base = Polygon([Point(0.0, 0.0, 0.0), Point(1.0, 0.0, 0.0), Point(1.0, 1.0, 0.0)]) >>> pyramid = Pyramid(base, apex) >>> composite = Composite(pyramid) >>> extracted_pyramid = composite.as_pyramid()
- as_ray( ) ostk.mathematics.geometry.d3.object.Ray ¶
Convert the composite to a Ray object.
- Returns:
The ray object contained in the composite.
- Return type:
- Raises:
RuntimeError -- If the composite does not contain a Ray.
Example
>>> ray = Ray(Point(0.0, 0.0, 0.0), numpy.array([1.0, 0.0, 0.0])) >>> composite = Composite(ray) >>> extracted_ray = composite.as_ray()
- as_segment( ) ostk.mathematics.geometry.d3.object.Segment ¶
Convert the composite to a Segment object.
- Returns:
The segment object contained in the composite.
- Return type:
- Raises:
RuntimeError -- If the composite does not contain a Segment.
Example
>>> segment = Segment(Point(0.0, 0.0, 0.0), Point(1.0, 1.0, 1.0)) >>> composite = Composite(segment) >>> extracted_segment = composite.as_segment()
- as_sphere( ) ostk.mathematics.geometry.d3.object.Sphere ¶
Convert the composite to a Sphere object.
- Returns:
The sphere object contained in the composite.
- Return type:
- Raises:
RuntimeError -- If the composite does not contain a Sphere.
Example
>>> sphere = Sphere(Point(0.0, 0.0, 0.0), 1.0) >>> composite = Composite(sphere) >>> extracted_sphere = composite.as_sphere()
- contains(*args, **kwargs)¶
Overloaded function.
contains(self: ostk.mathematics.geometry.d3.object.Composite, object: ostk.mathematics.geometry.d3.Object) -> bool
Check if the composite contains another geometric object.
- Args:
object (Object): The object to check containment for.
- Returns:
bool: True if the composite contains the object, False otherwise.
- Example:
>>> composite = Composite(Sphere(Point(0.0, 0.0, 0.0), 2.0)) >>> point = Point(0.5, 0.0, 0.0) >>> composite.contains(point) # True
contains(self: ostk.mathematics.geometry.d3.object.Composite, composite: ostk.mathematics.geometry.d3.object.Composite) -> bool
Check if the composite contains another composite.
- Args:
composite (Composite): The composite to check containment for.
- Returns:
bool: True if this composite contains the other composite, False otherwise.
- Example:
>>> outer_composite = Composite(Sphere(Point(0.0, 0.0, 0.0), 2.0)) >>> inner_composite = Composite(Sphere(Point(0.0, 0.0, 0.0), 1.0)) >>> outer_composite.contains(inner_composite) # True
- static empty() ostk.mathematics.geometry.d3.object.Composite ¶
Create an empty composite (containing no objects).
- Returns:
An empty composite object.
- Return type:
Example
>>> empty_composite = Composite.empty() >>> empty_composite.is_empty() # True >>> empty_composite.get_object_count() # 0
- get_object_count(self: ostk.mathematics.geometry.d3.object.Composite) int ¶
Get the number of objects contained in the composite.
- Returns:
The number of objects in the composite.
- Return type:
Example
>>> composite = Composite(Point(1.0, 2.0, 3.0)) >>> count = composite.get_object_count() # 1
- intersection_with(*args, **kwargs)¶
Overloaded function.
intersection_with(self: ostk.mathematics.geometry.d3.object.Composite, object: ostk.mathematics.geometry.d3.Object) -> ostk::mathematics::geometry::d3::Intersection
Compute the intersection of the composite with another geometric object.
- Args:
object (Object): The object to compute intersection with.
- Returns:
Intersection: The intersection result.
- Example:
>>> composite = Composite(Sphere(Point(0.0, 0.0, 0.0), 1.0)) >>> line = Line(Point(-2.0, 0.0, 0.0), numpy.array([1.0, 0.0, 0.0])) >>> intersection = composite.intersection_with(line)
intersection_with(self: ostk.mathematics.geometry.d3.object.Composite, composite: ostk.mathematics.geometry.d3.object.Composite) -> ostk::mathematics::geometry::d3::Intersection
Compute the intersection of the composite with another composite.
- Args:
composite (Composite): The composite to compute intersection with.
- Returns:
Intersection: The intersection result.
- Example:
>>> composite1 = Composite(Sphere(Point(0.0, 0.0, 0.0), 1.0)) >>> composite2 = Composite(Sphere(Point(1.5, 0.0, 0.0), 1.0)) >>> intersection = composite1.intersection_with(composite2)
- intersects(*args, **kwargs)¶
Overloaded function.
intersects(self: ostk.mathematics.geometry.d3.object.Composite, object: ostk.mathematics.geometry.d3.Object) -> bool
Check if the composite intersects with another geometric object.
- Args:
object (Object): The object to check intersection with.
- Returns:
bool: True if the composite intersects the object, False otherwise.
- Example:
>>> composite = Composite(Sphere(Point(0.0, 0.0, 0.0), 1.0)) >>> point = Point(0.5, 0.0, 0.0) >>> composite.intersects(point) # True
intersects(self: ostk.mathematics.geometry.d3.object.Composite, composite: ostk.mathematics.geometry.d3.object.Composite) -> bool
Check if the composite intersects with another composite.
- Args:
composite (Composite): The composite to check intersection with.
- Returns:
bool: True if the composites intersect, False otherwise.
- Example:
>>> composite1 = Composite(Sphere(Point(0.0, 0.0, 0.0), 1.0)) >>> composite2 = Composite(Sphere(Point(1.5, 0.0, 0.0), 1.0)) >>> composite1.intersects(composite2) # True
- is_composite(self: ostk.mathematics.geometry.d3.object.Composite) bool ¶
Check if the composite contains another Composite object.
- Returns:
True if the composite contains a Composite, False otherwise.
- Return type:
Example
>>> inner_composite = Composite(Point(1.0, 2.0, 3.0)) >>> outer_composite = Composite(inner_composite) >>> outer_composite.is_composite() # True
- is_cone(self: ostk.mathematics.geometry.d3.object.Composite) bool ¶
Check if the composite contains a Cone object.
- Returns:
True if the composite contains a Cone, False otherwise.
- Return type:
Example
>>> cone = Cone(Point(0.0, 0.0, 0.0), numpy.array([0.0, 0.0, 1.0]), Angle.degrees(30.0)) >>> composite = Composite(cone) >>> composite.is_cone() # True
- is_defined(self: ostk.mathematics.geometry.d3.object.Composite) bool ¶
Check if the composite is defined.
- Returns:
True if the composite is defined, False otherwise.
- Return type:
Example
>>> composite = Composite(Point(1.0, 2.0, 3.0)) >>> composite.is_defined() # True
- is_ellipsoid(self: ostk.mathematics.geometry.d3.object.Composite) bool ¶
Check if the composite contains an Ellipsoid object.
- Returns:
True if the composite contains an Ellipsoid, False otherwise.
- Return type:
Example
>>> ellipsoid = Ellipsoid(Point(0.0, 0.0, 0.0), 1.0, 0.8, 0.6) >>> composite = Composite(ellipsoid) >>> composite.is_ellipsoid() # True
- is_empty(self: ostk.mathematics.geometry.d3.object.Composite) bool ¶
Check if the composite is empty (contains no objects).
- Returns:
True if the composite is empty, False otherwise.
- Return type:
Example
>>> empty_composite = Composite.empty() >>> empty_composite.is_empty() # True
- is_line(self: ostk.mathematics.geometry.d3.object.Composite) bool ¶
Check if the composite contains a Line object.
- Returns:
True if the composite contains a Line, False otherwise.
- Return type:
Example
>>> line = Line(Point(0.0, 0.0, 0.0), numpy.array([1.0, 0.0, 0.0])) >>> composite = Composite(line) >>> composite.is_line() # True
- is_line_string(self: ostk.mathematics.geometry.d3.object.Composite) bool ¶
Check if the composite contains a LineString object.
- Returns:
True if the composite contains a LineString, False otherwise.
- Return type:
Example
>>> points = [Point(0.0, 0.0, 0.0), Point(1.0, 1.0, 1.0), Point(2.0, 2.0, 2.0)] >>> line_string = LineString(points) >>> composite = Composite(line_string) >>> composite.is_line_string() # True
- is_plane(self: ostk.mathematics.geometry.d3.object.Composite) bool ¶
Check if the composite contains a Plane object.
- Returns:
True if the composite contains a Plane, False otherwise.
- Return type:
Example
>>> plane = Plane(Point(0.0, 0.0, 0.0), numpy.array([0.0, 0.0, 1.0])) >>> composite = Composite(plane) >>> composite.is_plane() # True
- is_point(self: ostk.mathematics.geometry.d3.object.Composite) bool ¶
Check if the composite contains a Point object.
- Returns:
True if the composite contains a Point, False otherwise.
- Return type:
Example
>>> composite = Composite(Point(1.0, 2.0, 3.0)) >>> composite.is_point() # True
- is_point_set(self: ostk.mathematics.geometry.d3.object.Composite) bool ¶
Check if the composite contains a PointSet object.
- Returns:
True if the composite contains a PointSet, False otherwise.
- Return type:
Example
>>> point_set = PointSet([Point(1.0, 2.0, 3.0), Point(4.0, 5.0, 6.0)]) >>> composite = Composite(point_set) >>> composite.is_point_set() # True
- is_polygon(self: ostk.mathematics.geometry.d3.object.Composite) bool ¶
Check if the composite contains a Polygon object.
- Returns:
True if the composite contains a Polygon, False otherwise.
- Return type:
Example
>>> vertices = [Point(0.0, 0.0, 0.0), Point(1.0, 0.0, 0.0), Point(1.0, 1.0, 0.0)] >>> polygon = Polygon(vertices) >>> composite = Composite(polygon) >>> composite.is_polygon() # True
- is_pyramid(self: ostk.mathematics.geometry.d3.object.Composite) bool ¶
Check if the composite contains a Pyramid object.
- Returns:
True if the composite contains a Pyramid, False otherwise.
- Return type:
Example
>>> apex = Point(0.0, 0.0, 1.0) >>> base = Polygon([Point(0.0, 0.0, 0.0), Point(1.0, 0.0, 0.0), Point(1.0, 1.0, 0.0)]) >>> pyramid = Pyramid(base, apex) >>> composite = Composite(pyramid) >>> composite.is_pyramid() # True
- is_ray(self: ostk.mathematics.geometry.d3.object.Composite) bool ¶
Check if the composite contains a Ray object.
- Returns:
True if the composite contains a Ray, False otherwise.
- Return type:
Example
>>> ray = Ray(Point(0.0, 0.0, 0.0), numpy.array([1.0, 0.0, 0.0])) >>> composite = Composite(ray) >>> composite.is_ray() # True
- is_segment(self: ostk.mathematics.geometry.d3.object.Composite) bool ¶
Check if the composite contains a Segment object.
- Returns:
True if the composite contains a Segment, False otherwise.
- Return type:
Example
>>> segment = Segment(Point(0.0, 0.0, 0.0), Point(1.0, 1.0, 1.0)) >>> composite = Composite(segment) >>> composite.is_segment() # True
- is_sphere(self: ostk.mathematics.geometry.d3.object.Composite) bool ¶
Check if the composite contains a Sphere object.
- Returns:
True if the composite contains a Sphere, False otherwise.
- Return type:
Example
>>> sphere = Sphere(Point(0.0, 0.0, 0.0), 1.0) >>> composite = Composite(sphere) >>> composite.is_sphere() # True
- static undefined() ostk.mathematics.geometry.d3.object.Composite ¶
Create an undefined composite.
- Returns:
An undefined composite object.
- Return type:
Example
>>> undefined_composite = Composite.undefined() >>> undefined_composite.is_defined() # False