ostk.mathematics.geometry.d2.object.Line

class Line(
self: ostk.mathematics.geometry.d2.object.Line,
point: ostk.mathematics.geometry.d2.object.Point,
direction: numpy.ndarray[numpy.float64[2, 1]],
)

Bases: Object

Create a 2D line with a point and direction vector.

Parameters:
  • point (Point) -- A point on the line.

  • direction (numpy.array) -- The direction vector of the line.

Example

>>> point = Point(0.0, 0.0)
>>> direction = numpy.array([1.0, 1.0])
>>> line = Line(point, direction)

Methods

apply_transformation

Apply a transformation to the line in place.

contains

Overloaded function.

distance_to

Calculate the distance from the line to a point.

get_direction

Get the direction vector of the line.

get_origin

Get the origin point of the line.

intersects

Check if the line intersects with a point.

is_defined

Check if the line is defined.

points

Create a line passing through two points.

undefined

Create an undefined line.

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.Line,
transformation: ostk::mathematics::geometry::d2::Transformation,
) None

Apply a transformation to the line in place.

Parameters:

transformation (Transformation) -- The transformation to apply.

Example

>>> line = Line.points(Point(0.0, 0.0), Point(1.0, 0.0))
>>> transformation = Translation([1.0, 1.0])
>>> line.apply_transformation(transformation)
contains(*args, **kwargs)

Overloaded function.

  1. contains(self: ostk.mathematics.geometry.d2.object.Line, point: ostk.mathematics.geometry.d2.object.Point) -> bool

    Check if the line contains a point.

    Args:

    point (Point): The point to check.

    Returns:

    bool: True if the line contains the point, False otherwise.

    Example:
    >>> line = Line.points(Point(0.0, 0.0), Point(1.0, 1.0))
    >>> line.contains(Point(0.5, 0.5))  # True
    
  2. contains(self: ostk.mathematics.geometry.d2.object.Line, point_set: ostk.mathematics.geometry.d2.object.PointSet) -> bool

    Check if the line contains all points in a point set.

    Args:

    point_set (PointSet): The set of points to check.

    Returns:

    bool: True if the line contains all points in the set, False otherwise.

    Example:
    >>> line = Line.points(Point(0.0, 0.0), Point(1.0, 1.0))
    >>> points = PointSet([Point(0.5, 0.5), Point(0.25, 0.25)])
    >>> line.contains(points)
    
distance_to(
self: ostk.mathematics.geometry.d2.object.Line,
point: ostk.mathematics.geometry.d2.object.Point,
) ostk.core.type.Real

Calculate the distance from the line to a point.

Parameters:

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

Returns:

The distance from the line to the point.

Return type:

float

Example

>>> line = Line.points(Point(0.0, 0.0), Point(1.0, 0.0))
>>> distance = line.distance_to(Point(0.5, 1.0))  # 1.0
get_direction(
self: ostk.mathematics.geometry.d2.object.Line,
) numpy.ndarray[numpy.float64[2, 1]]

Get the direction vector of the line.

Returns:

The direction vector of the line.

Return type:

Vector2d

Example

>>> line = Line.points(Point(0.0, 0.0), Point(1.0, 1.0))
>>> direction = line.get_direction()
get_origin(
self: ostk.mathematics.geometry.d2.object.Line,
) ostk.mathematics.geometry.d2.object.Point

Get the origin point of the line.

Returns:

The origin point of the line.

Return type:

Point

Example

>>> line = Line.points(Point(1.0, 2.0), Point(3.0, 4.0))
>>> origin = line.get_origin()
intersects(
self: ostk.mathematics.geometry.d2.object.Line,
point: ostk.mathematics.geometry.d2.object.Point,
) bool

Check if the line intersects with a point.

Parameters:

point (Point) -- The point to check intersection with.

Returns:

True if the line intersects with the point, False otherwise.

Return type:

bool

Example

>>> line = Line.points(Point(0.0, 0.0), Point(1.0, 1.0))
>>> line.intersects(Point(0.5, 0.5))  # True
is_defined(self: ostk.mathematics.geometry.d2.object.Line) bool

Check if the line is defined.

Returns:

True if the line is defined, False otherwise.

Return type:

bool

Example

>>> line = Line.points(Point(0.0, 0.0), Point(1.0, 1.0))
>>> line.is_defined()  # True
static points(
first_point: ostk.mathematics.geometry.d2.object.Point,
second_point: ostk.mathematics.geometry.d2.object.Point,
) ostk.mathematics.geometry.d2.object.Line

Create a line passing through two points.

Parameters:
  • first_point (Point) -- The first point.

  • second_point (Point) -- The second point.

Returns:

A line passing through both points.

Return type:

Line

Example

>>> point1 = Point(0.0, 0.0)
>>> point2 = Point(1.0, 1.0)
>>> line = Line.points(point1, point2)
static undefined() ostk.mathematics.geometry.d2.object.Line

Create an undefined line.

Returns:

An undefined line.

Return type:

Line

Example

>>> undefined_line = Line.undefined()
>>> undefined_line.is_defined()  # False