ostk.mathematics.geometry.d2.object.Composite

class Composite(
self: ostk.mathematics.geometry.d2.object.Composite,
object: ostk.mathematics.geometry.d2.Object,
)

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_object_at

Access the object at a specific index in the 2D composite.

any_contains

Overloaded function.

apply_transformation

Apply a transformation to all objects in the 2D composite in place.

as_composite

Convert the composite to a 2D Composite object.

as_line

Convert the composite to a 2D Line object.

as_line_string

Convert the composite to a 2D LineString object.

as_point

Convert the composite to a 2D Point object.

as_point_set

Convert the composite to a 2D PointSet object.

as_polygon

Convert the composite to a 2D Polygon object.

as_segment

Convert the composite to a 2D Segment object.

contains

Overloaded function.

empty

Create an empty 2D composite (containing no objects).

get_object_count

Get the number of objects contained in the 2D composite.

intersects

Overloaded function.

is_composite

Check if the composite contains another 2D Composite object.

is_defined

Check if the 2D composite is defined.

is_empty

Check if the 2D composite is empty (contains no objects).

is_line

Check if the composite contains a 2D Line object.

is_line_string

Check if the composite contains a 2D LineString object.

is_point

Check if the composite contains a 2D Point object.

is_point_set

Check if the composite contains a 2D PointSet object.

is_polygon

Check if the composite contains a 2D Polygon object.

is_segment

Check if the composite contains a 2D Segment object.

undefined

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,
) ostk.mathematics.geometry.d2.object.Composite
access_object_at(
self: ostk.mathematics.geometry.d2.object.Composite,
index: int,
) ostk.mathematics.geometry.d2.Object

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:

Object

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.

  1. 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
    
  2. 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,
) None

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(
self: ostk.mathematics.geometry.d2.object.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:

Composite

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(
self: ostk.mathematics.geometry.d2.object.Composite,
) ostk.mathematics.geometry.d2.object.Line

Convert the composite to a 2D Line object.

Returns:

The line object contained in the composite.

Return type:

Line

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(
self: ostk.mathematics.geometry.d2.object.Composite,
) 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:

LineString

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(
self: ostk.mathematics.geometry.d2.object.Composite,
) ostk.mathematics.geometry.d2.object.Point

Convert the composite to a 2D Point object.

Returns:

The point object contained in the composite.

Return type:

Point

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(
self: ostk.mathematics.geometry.d2.object.Composite,
) 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:

PointSet

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(
self: ostk.mathematics.geometry.d2.object.Composite,
) ostk.mathematics.geometry.d2.object.Polygon

Convert the composite to a 2D Polygon object.

Returns:

The polygon object contained in the composite.

Return type:

Polygon

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(
self: ostk.mathematics.geometry.d2.object.Composite,
) ostk.mathematics.geometry.d2.object.Segment

Convert the composite to a 2D Segment object.

Returns:

The segment object contained in the composite.

Return type:

Segment

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.

  1. 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
    
  2. 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:

Composite

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:

int

Example

>>> composite = Composite(Point(1.0, 2.0))
>>> count = composite.get_object_count()  # 1
intersects(*args, **kwargs)

Overloaded function.

  1. 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
    
  2. 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:

bool

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:

bool

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:

bool

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:

bool

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:

bool

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:

bool

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:

bool

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:

bool

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:

bool

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:

Composite

Example

>>> undefined_composite = Composite.undefined()
>>> undefined_composite.is_defined()  # False