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.
Example
>>> points = [Point(0.0, 0.0), Point(1.0, 1.0), Point(2.0, 2.0)] >>> point_set = PointSet(points)
Methods
Apply a transformation to all points in the set.
Check if this 2D object contains another object.
Calculate the distance from the point set to a point.
Create an empty point set.
Get the point in the set that is closest to a given point.
Get the number of points in the set.
Check if this 2D object intersects with another object.
Check if the point set is defined.
Check if the point set is empty (contains no points).
Check if this point set is near another point set within tolerance.
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,
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( ) 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:
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,
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:
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:
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,
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:
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:
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( ) 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:
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:
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:
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,
- point_set: ostk.mathematics.geometry.d2.object.PointSet,
Check if this point set is near another point set within tolerance.
- Parameters:
- Returns:
True if point sets are within tolerance, False otherwise.
- Return type:
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,
- format: ostk.mathematics.geometry.d2.Object.Format = <Format.Standard: 1>,
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:
Example
>>> points = [Point(0.0, 0.0), Point(1.0, 1.0)] >>> point_set = PointSet(points) >>> point_set.to_string()