ostk.mathematics.geometry.d2.object.Point

class Point(
self: ostk.mathematics.geometry.d2.object.Point,
x: ostk.core.type.Real,
y: ostk.core.type.Real,
)

Bases: Object

Create a 2D point with specified coordinates.

Parameters:
  • x (float) -- The x-coordinate.

  • y (float) -- The y-coordinate.

Example

>>> point = Point(1.0, 2.0)
>>> point.x()  # 1.0
>>> point.y()  # 2.0

Methods

apply_transformation

Apply a transformation to the point in place.

as_vector

Convert the point to a 2D vector.

contains

Check if this 2D object contains another object.

distance_to

Calculate the distance to another point.

intersects

Check if this 2D object intersects with another object.

is_defined

Check if the point is defined.

is_near

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

origin

Create a point at the origin (0, 0).

to_string

Convert the point to a string representation.

undefined

Create an undefined point.

vector

Create a point from a 2D vector.

x

Get the x-coordinate of the point.

y

Get the y-coordinate of the point.

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.Point,
arg0: numpy.ndarray[numpy.float64[2, 1]],
) ostk.mathematics.geometry.d2.object.Point
apply_transformation(
self: ostk.mathematics.geometry.d2.object.Point,
transformation: ostk::mathematics::geometry::d2::Transformation,
) None

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

Calculate the distance to another point.

Parameters:

point (Point) -- The other point.

Returns:

The distance between the points.

Return type:

float

Example

>>> point1 = Point(0.0, 0.0)
>>> point2 = Point(3.0, 4.0)
>>> point1.distance_to(point2)  # 5.0
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.Point) bool

Check if the point is defined.

Returns:

True if the point is defined, False otherwise.

Return type:

bool

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,
) bool

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

Parameters:
  • point (Point) -- The point to compare with.

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

Returns:

True if points are within tolerance, False otherwise.

Return type:

bool

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:

Point

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,
) ostk.core.type.String

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:

str

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:

Point

Example

>>> undefined_point = Point.undefined()
>>> undefined_point.is_defined()  # False
static vector(
vector: numpy.ndarray[numpy.float64[2, 1]],
) ostk.mathematics.geometry.d2.object.Point

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:

Point

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:

float

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:

float

Example

>>> point = Point(1.0, 2.0)
>>> point.y()  # 2.0