ostk.mathematics.geometry.d2.object.Point¶
- class Point( )¶
Bases:
ObjectCreate a 2D point with specified coordinates.
Example
>>> point = Point(1.0, 2.0) >>> point.x() # 1.0 >>> point.y() # 2.0
Methods
Apply a transformation to the point in place.
Convert the point to a 2D vector.
Check if this 2D object contains another object.
Calculate the distance to another point.
Check if this 2D object intersects with another object.
Check if the point is defined.
Check if this point is near another point within a tolerance.
Create a point at the origin (0, 0).
Convert the point to a string representation.
Create an undefined point.
Create a point from a 2D vector.
Get the x-coordinate of the point.
Get the y-coordinate of the point.
- class Format(self: ostk.mathematics.geometry.d2.Object.Format, value: int)¶
Bases:
pybind11_objectMembers:
Undefined
Standard
WKT
- property name¶
- __add__(
- self: ostk.mathematics.geometry.d2.object.Point,
- arg0: numpy.ndarray[numpy.float64[2, 1]],
- apply_transformation(
- self: ostk.mathematics.geometry.d2.object.Point,
- transformation: ostk::mathematics::geometry::d2::Transformation,
Apply a transformation to the point in place.
- Parameters:
transformation (Transformation) -- The transformation to apply.
Example
>>> point = Point(1.0, 2.0) >>> transformation = Translation([1.0, 1.0]) >>> point.apply_transformation(transformation)
- as_vector( ) numpy.ndarray[numpy.float64[2, 1]]¶
Convert the point to a 2D vector.
- Returns:
The point as a 2D vector.
- Return type:
Vector2d
Example
>>> point = Point(1.0, 2.0) >>> vector = point.as_vector() # numpy.array([1.0, 2.0])
- 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( ) ostk.core.type.Real¶
Calculate the distance to another point.
- Parameters:
point (Point) -- The other point.
- Returns:
The distance between the points.
- Return type:
Example
>>> point1 = Point(0.0, 0.0) >>> point2 = Point(3.0, 4.0) >>> point1.distance_to(point2) # 5.0
- 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.Point) bool¶
Check if the point is defined.
- Returns:
True if the point is defined, False otherwise.
- Return type:
Example
>>> point = Point(1.0, 2.0) >>> point.is_defined() # True
- is_near(
- self: ostk.mathematics.geometry.d2.object.Point,
- point: ostk.mathematics.geometry.d2.object.Point,
- tolerance: ostk.core.type.Real,
- point: ostk.mathematics.geometry.d2.object.Point,
Check if this point is near another point within a tolerance.
- Parameters:
- Returns:
True if points are within tolerance, False otherwise.
- Return type:
Example
>>> point1 = Point(1.0, 2.0) >>> point2 = Point(1.1, 2.1) >>> point1.is_near(point2, 0.2) # True
- static origin() ostk.mathematics.geometry.d2.object.Point¶
Create a point at the origin (0, 0).
- Returns:
A point at coordinates (0, 0).
- Return type:
Example
>>> origin = Point.origin() >>> origin.x() # 0.0 >>> origin.y() # 0.0
- to_string(
- self: ostk.mathematics.geometry.d2.object.Point,
- 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 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.
- Return type:
Example
>>> point = Point(1.0, 2.0) >>> point.to_string() # "(1.0, 2.0)"
- static undefined() ostk.mathematics.geometry.d2.object.Point¶
Create an undefined point.
- Returns:
An undefined point.
- Return type:
Example
>>> undefined_point = Point.undefined() >>> undefined_point.is_defined() # False
- static vector(
- vector: numpy.ndarray[numpy.float64[2, 1]],
Create a point from a 2D vector.
- Parameters:
vector (numpy.array) -- The vector to convert to a point.
- Returns:
A point with coordinates from the vector.
- Return type:
Example
>>> vector = numpy.array([1.0, 2.0]) >>> point = Point.vector(vector) # Point(1.0, 2.0)
- x(self: ostk.mathematics.geometry.d2.object.Point) ostk.core.type.Real¶
Get the x-coordinate of the point.
- Returns:
The x-coordinate.
- Return type:
Example
>>> point = Point(1.0, 2.0) >>> point.x() # 1.0
- y(self: ostk.mathematics.geometry.d2.object.Point) ostk.core.type.Real¶
Get the y-coordinate of the point.
- Returns:
The y-coordinate.
- Return type:
Example
>>> point = Point(1.0, 2.0) >>> point.y() # 2.0