ostk.mathematics.geometry.d2.object.PointSet

class PointSet(
self: ostk.mathematics.geometry.d2.object.PointSet,
points: list[ostk.mathematics.geometry.d2.object.Point],
)

Bases: Object

Create a 2D point set from an array of points.

Parameters:

points (list[Point]) -- List of Point objects to include in the set.

Example

>>> points = [Point(0.0, 0.0), Point(1.0, 1.0), Point(2.0, 2.0)]
>>> point_set = PointSet(points)

Methods

apply_transformation

Apply a transformation to all points in the set.

contains

Check if this 2D object contains another object.

distance_to

Calculate the distance from the point set to a point.

empty

Create an empty point set.

get_point_closest_to

Get the point in the set that is closest to a given point.

get_size

Get the number of points in the set.

intersects

Check if this 2D object intersects with another object.

is_defined

Check if the point set is defined.

is_empty

Check if the point set is empty (contains no points).

is_near

Check if this point set is near another point set within tolerance.

to_string

Convert the point set to a string representation.

class Format(self: ostk.mathematics.geometry.d2.Object.Format, value: int)

Bases: pybind11_object

Members:

Undefined

Standard

WKT

property name
apply_transformation(
self: ostk.mathematics.geometry.d2.object.PointSet,
transformation: ostk::mathematics::geometry::d2::Transformation,
) None

Apply a transformation to all points in the set.

Parameters:

transformation (Transformation) -- The 2D transformation to apply.

Example

>>> points = [Point(0.0, 0.0), Point(1.0, 1.0)]
>>> point_set = PointSet(points)
>>> transformation = Translation([1.0, 1.0])
>>> point_set.apply_transformation(transformation)
contains(
self: ostk.mathematics.geometry.d2.Object,
object: ostk.mathematics.geometry.d2.Object,
) bool

Check if this 2D object contains another object.

Parameters:

object (Object) -- The object to check containment for.

Returns:

True if this object contains the other, False otherwise.

Return type:

bool

Example

>>> polygon = Polygon([Point(0.0, 0.0), Point(2.0, 0.0), Point(2.0, 2.0)])
>>> point = Point(1.0, 1.0)
>>> polygon.contains(point)  # True
distance_to(
self: ostk.mathematics.geometry.d2.object.PointSet,
point: ostk.mathematics.geometry.d2.object.Point,
) ostk.core.type.Real

Calculate the distance from the point set to a point.

Parameters:

point (Point) -- The point to calculate distance to.

Returns:

The minimum distance from any point in the set to the given point.

Return type:

float

Example

>>> points = [Point(0.0, 0.0), Point(2.0, 0.0)]
>>> point_set = PointSet(points)
>>> distance = point_set.distance_to(Point(1.0, 0.0))  # 1.0
static empty() ostk.mathematics.geometry.d2.object.PointSet

Create an empty point set.

Returns:

An empty point set containing no points.

Return type:

PointSet

Example

>>> empty_set = PointSet.empty()
>>> empty_set.is_empty()  # True
>>> empty_set.get_size()  # 0
get_point_closest_to(
self: ostk.mathematics.geometry.d2.object.PointSet,
point: ostk.mathematics.geometry.d2.object.Point,
) ostk.mathematics.geometry.d2.object.Point

Get the point in the set that is closest to a given point.

Parameters:

point (Point) -- The reference point.

Returns:

The closest point in the set to the given point.

Return type:

Point

Example

>>> points = [Point(0.0, 0.0), Point(2.0, 0.0), Point(4.0, 0.0)]
>>> point_set = PointSet(points)
>>> closest = point_set.get_point_closest_to(Point(1.5, 0.0))  # Point(2.0, 0.0)
get_size(self: ostk.mathematics.geometry.d2.object.PointSet) int

Get the number of points in the set.

Returns:

The number of points in the set.

Return type:

int

Example

>>> points = [Point(0.0, 0.0), Point(1.0, 1.0), Point(2.0, 2.0)]
>>> point_set = PointSet(points)
>>> point_set.get_size()  # 3
intersects(
self: ostk.mathematics.geometry.d2.Object,
object: ostk.mathematics.geometry.d2.Object,
) bool

Check if this 2D object intersects with another object.

Parameters:

object (Object) -- The object to check intersection with.

Returns:

True if objects intersect, False otherwise.

Return type:

bool

Example

>>> line1 = Line(Point(0.0, 0.0), numpy.array([1.0, 0.0]))
>>> line2 = Line(Point(0.0, -1.0), numpy.array([0.0, 1.0]))
>>> line1.intersects(line2)  # True
is_defined(self: ostk.mathematics.geometry.d2.object.PointSet) bool

Check if the point set is defined.

Returns:

True if the point set is defined, False otherwise.

Return type:

bool

Example

>>> points = [Point(0.0, 0.0), Point(1.0, 1.0)]
>>> point_set = PointSet(points)
>>> point_set.is_defined()  # True
is_empty(self: ostk.mathematics.geometry.d2.object.PointSet) bool

Check if the point set is empty (contains no points).

Returns:

True if the point set is empty, False otherwise.

Return type:

bool

Example

>>> empty_set = PointSet.empty()
>>> empty_set.is_empty()  # True
>>> points = [Point(0.0, 0.0)]
>>> point_set = PointSet(points)
>>> point_set.is_empty()  # False
is_near(
self: ostk.mathematics.geometry.d2.object.PointSet,
point_set: ostk.mathematics.geometry.d2.object.PointSet,
tolerance: ostk.core.type.Real,
) bool

Check if this point set is near another point set within tolerance.

Parameters:
  • point_set (PointSet) -- The point set to compare with.

  • tolerance (float) -- The tolerance for comparison.

Returns:

True if point sets are within tolerance, False otherwise.

Return type:

bool

Example

>>> points1 = [Point(0.0, 0.0), Point(1.0, 1.0)]
>>> points2 = [Point(0.1, 0.1), Point(1.1, 1.1)]
>>> set1 = PointSet(points1)
>>> set2 = PointSet(points2)
>>> set1.is_near(set2, 0.2)  # True
to_string(
self: ostk.mathematics.geometry.d2.object.PointSet,
format: ostk.mathematics.geometry.d2.Object.Format = <Format.Standard: 1>,
precision: ostk.core.type.Integer = Undefined,
) ostk.core.type.String

Convert the point set to a string representation.

Parameters:
  • format (Object.Format, optional) -- The output format. Defaults to Standard.

  • precision (int, optional) -- The precision for floating point numbers. Defaults to undefined.

Returns:

String representation of the point set.

Return type:

str

Example

>>> points = [Point(0.0, 0.0), Point(1.0, 1.0)]
>>> point_set = PointSet(points)
>>> point_set.to_string()