ostk.mathematics.geometry.d2.object.Composite¶
- class Composite( )¶
Bases:
Object
Create a 2D composite object from a single geometric object.
- Parameters:
object (Object) -- The 2D geometric object to wrap in the composite.
Example
>>> point = Point(1.0, 2.0) >>> composite = Composite(point)
Methods
Access the object at a specific index in the 2D composite.
Overloaded function.
Apply a transformation to all objects in the 2D composite in place.
Convert the composite to a 2D Composite object.
Convert the composite to a 2D Line object.
Convert the composite to a 2D LineString object.
Convert the composite to a 2D Point object.
Convert the composite to a 2D PointSet object.
Convert the composite to a 2D Polygon object.
Convert the composite to a 2D Segment object.
Overloaded function.
Create an empty 2D composite (containing no objects).
Get the number of objects contained in the 2D composite.
Overloaded function.
Check if the composite contains another 2D Composite object.
Check if the 2D composite is defined.
Check if the 2D composite is empty (contains no objects).
Check if the composite contains a 2D Line object.
Check if the composite contains a 2D LineString object.
Check if the composite contains a 2D Point object.
Check if the composite contains a 2D PointSet object.
Check if the composite contains a 2D Polygon object.
Check if the composite contains a 2D Segment object.
Create an undefined 2D composite.
- class Format(self: ostk.mathematics.geometry.d2.Object.Format, value: int)¶
Bases:
pybind11_object
Members:
Undefined
Standard
WKT
- property name¶
- __add__(
- self: ostk.mathematics.geometry.d2.object.Composite,
- arg0: ostk.mathematics.geometry.d2.object.Composite,
- access_object_at(
- self: ostk.mathematics.geometry.d2.object.Composite,
- index: int,
Access the object at a specific index in the 2D 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)) >>> obj = composite.access_object_at(0)
- any_contains(*args, **kwargs)¶
Overloaded function.
any_contains(self: ostk.mathematics.geometry.d2.object.Composite, object: ostk.mathematics.geometry.d2.Object) -> bool
Check if any object in the 2D composite contains another geometric object.
- Args:
object (Object): The 2D object to check containment for.
- Returns:
bool: True if any object in the composite contains the object, False otherwise.
- Example:
>>> polygon1 = Polygon([Point(0.0, 0.0), Point(1.0, 0.0), Point(1.0, 1.0)]) >>> polygon2 = Polygon([Point(2.0, 2.0), Point(3.0, 2.0), Point(3.0, 3.0)]) >>> composite = Composite(polygon1) + Composite(polygon2) >>> point = Point(0.5, 0.5) >>> composite.any_contains(point) # True
any_contains(self: ostk.mathematics.geometry.d2.object.Composite, composite: ostk.mathematics.geometry.d2.object.Composite) -> bool
Check if any object in the 2D composite contains another composite.
- Args:
composite (Composite): The composite to check containment for.
- Returns:
bool: True if any object in this composite contains the other composite, False otherwise.
- Example:
>>> outer_polygon = Polygon([Point(0.0, 0.0), Point(3.0, 0.0), Point(3.0, 3.0)]) >>> composite1 = Composite(outer_polygon) >>> inner_composite = Composite(Point(1.5, 1.5)) >>> composite1.any_contains(inner_composite) # True
- apply_transformation(
- self: ostk.mathematics.geometry.d2.object.Composite,
- transformation: ostk::mathematics::geometry::d2::Transformation,
Apply a transformation to all objects in the 2D composite in place.
- Parameters:
transformation (Transformation) -- The 2D transformation to apply.
Example
>>> composite = Composite(Point(1.0, 2.0)) >>> transformation = Translation([1.0, 1.0]) >>> composite.apply_transformation(transformation)
- as_composite( ) ostk.mathematics.geometry.d2.object.Composite ¶
Convert the composite to a 2D 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)) >>> outer_composite = Composite(inner_composite) >>> extracted_composite = outer_composite.as_composite()
- as_line( ) ostk.mathematics.geometry.d2.object.Line ¶
Convert the composite to a 2D 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), numpy.array([1.0, 1.0])) >>> composite = Composite(line) >>> extracted_line = composite.as_line()
- as_line_string( ) ostk.mathematics.geometry.d2.object.LineString ¶
Convert the composite to a 2D 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), Point(1.0, 1.0), Point(2.0, 2.0)] >>> line_string = LineString(points) >>> composite = Composite(line_string) >>> extracted_line_string = composite.as_line_string()
- as_point( ) ostk.mathematics.geometry.d2.object.Point ¶
Convert the composite to a 2D 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)) >>> point = composite.as_point()
- as_point_set( ) ostk.mathematics.geometry.d2.object.PointSet ¶
Convert the composite to a 2D 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), Point(3.0, 4.0)]) >>> composite = Composite(point_set) >>> extracted_set = composite.as_point_set()
- as_polygon( ) ostk.mathematics.geometry.d2.object.Polygon ¶
Convert the composite to a 2D 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), Point(1.0, 0.0), Point(1.0, 1.0)] >>> polygon = Polygon(vertices) >>> composite = Composite(polygon) >>> extracted_polygon = composite.as_polygon()
- as_segment( ) ostk.mathematics.geometry.d2.object.Segment ¶
Convert the composite to a 2D 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), Point(1.0, 1.0)) >>> composite = Composite(segment) >>> extracted_segment = composite.as_segment()
- contains(*args, **kwargs)¶
Overloaded function.
contains(self: ostk.mathematics.geometry.d2.object.Composite, object: ostk.mathematics.geometry.d2.Object) -> bool
Check if the 2D composite contains another geometric object.
- Args:
object (Object): The 2D object to check containment for.
- Returns:
bool: True if the composite contains the object, False otherwise.
- Example:
>>> composite = Composite(Polygon([Point(0.0, 0.0), Point(2.0, 0.0), Point(2.0, 2.0)])) >>> point = Point(1.0, 1.0) >>> composite.contains(point) # True
contains(self: ostk.mathematics.geometry.d2.object.Composite, composite: ostk.mathematics.geometry.d2.object.Composite) -> bool
Check if the 2D 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(Polygon([Point(0.0, 0.0), Point(3.0, 0.0), Point(3.0, 3.0)])) >>> inner_composite = Composite(Polygon([Point(1.0, 1.0), Point(2.0, 1.0), Point(2.0, 2.0)])) >>> outer_composite.contains(inner_composite) # True
- static empty() ostk.mathematics.geometry.d2.object.Composite ¶
Create an empty 2D 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.d2.object.Composite) int ¶
Get the number of objects contained in the 2D composite.
- Returns:
The number of objects in the composite.
- Return type:
Example
>>> composite = Composite(Point(1.0, 2.0)) >>> count = composite.get_object_count() # 1
- intersects(*args, **kwargs)¶
Overloaded function.
intersects(self: ostk.mathematics.geometry.d2.object.Composite, object: ostk.mathematics.geometry.d2.Object) -> bool
Check if the 2D composite intersects with another geometric object.
- Args:
object (Object): The 2D object to check intersection with.
- Returns:
bool: True if the composite intersects the object, False otherwise.
- Example:
>>> composite = Composite(Polygon([Point(0.0, 0.0), Point(1.0, 0.0), Point(1.0, 1.0)])) >>> point = Point(0.5, 0.5) >>> composite.intersects(point) # True
intersects(self: ostk.mathematics.geometry.d2.object.Composite, composite: ostk.mathematics.geometry.d2.object.Composite) -> bool
Check if the 2D 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(Polygon([Point(0.0, 0.0), Point(1.0, 0.0), Point(1.0, 1.0)])) >>> composite2 = Composite(Polygon([Point(0.5, 0.5), Point(1.5, 0.5), Point(1.5, 1.5)])) >>> composite1.intersects(composite2) # True
- is_composite(self: ostk.mathematics.geometry.d2.object.Composite) bool ¶
Check if the composite contains another 2D Composite object.
- Returns:
True if the composite contains a Composite, False otherwise.
- Return type:
Example
>>> inner_composite = Composite(Point(1.0, 2.0)) >>> outer_composite = Composite(inner_composite) >>> outer_composite.is_composite() # True
- is_defined(self: ostk.mathematics.geometry.d2.object.Composite) bool ¶
Check if the 2D composite is defined.
- Returns:
True if the composite is defined, False otherwise.
- Return type:
Example
>>> composite = Composite(Point(1.0, 2.0)) >>> composite.is_defined() # True
- is_empty(self: ostk.mathematics.geometry.d2.object.Composite) bool ¶
Check if the 2D 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.d2.object.Composite) bool ¶
Check if the composite contains a 2D Line object.
- Returns:
True if the composite contains a Line, False otherwise.
- Return type:
Example
>>> line = Line(Point(0.0, 0.0), numpy.array([1.0, 1.0])) >>> composite = Composite(line) >>> composite.is_line() # True
- is_line_string(self: ostk.mathematics.geometry.d2.object.Composite) bool ¶
Check if the composite contains a 2D LineString object.
- Returns:
True if the composite contains a LineString, False otherwise.
- Return type:
Example
>>> points = [Point(0.0, 0.0), Point(1.0, 1.0), Point(2.0, 2.0)] >>> line_string = LineString(points) >>> composite = Composite(line_string) >>> composite.is_line_string() # True
- is_point(self: ostk.mathematics.geometry.d2.object.Composite) bool ¶
Check if the composite contains a 2D Point object.
- Returns:
True if the composite contains a Point, False otherwise.
- Return type:
Example
>>> composite = Composite(Point(1.0, 2.0)) >>> composite.is_point() # True
- is_point_set(self: ostk.mathematics.geometry.d2.object.Composite) bool ¶
Check if the composite contains a 2D PointSet object.
- Returns:
True if the composite contains a PointSet, False otherwise.
- Return type:
Example
>>> point_set = PointSet([Point(1.0, 2.0), Point(3.0, 4.0)]) >>> composite = Composite(point_set) >>> composite.is_point_set() # True
- is_polygon(self: ostk.mathematics.geometry.d2.object.Composite) bool ¶
Check if the composite contains a 2D Polygon object.
- Returns:
True if the composite contains a Polygon, False otherwise.
- Return type:
Example
>>> vertices = [Point(0.0, 0.0), Point(1.0, 0.0), Point(1.0, 1.0)] >>> polygon = Polygon(vertices) >>> composite = Composite(polygon) >>> composite.is_polygon() # True
- is_segment(self: ostk.mathematics.geometry.d2.object.Composite) bool ¶
Check if the composite contains a 2D Segment object.
- Returns:
True if the composite contains a Segment, False otherwise.
- Return type:
Example
>>> segment = Segment(Point(0.0, 0.0), Point(1.0, 1.0)) >>> composite = Composite(segment) >>> composite.is_segment() # True
- static undefined() ostk.mathematics.geometry.d2.object.Composite ¶
Create an undefined 2D composite.
- Returns:
An undefined composite object.
- Return type:
Example
>>> undefined_composite = Composite.undefined() >>> undefined_composite.is_defined() # False