ostk.mathematics.geometry.d3.object.Line

class Line(
self: ostk.mathematics.geometry.d3.object.Line,
origin: ostk.mathematics.geometry.d3.object.Point,
direction: numpy.ndarray[numpy.float64[3, 1]],
)

Bases: Object

An infinite line in 3D space.

A Line is defined by an origin point and a direction vector.

Example

>>> line = Line.points(Point(0.0, 0.0), Point(1.0, 0.0))
>>> line.is_defined()  # True

Construct a line from an origin point and direction vector.

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

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

Example

>>> line = Line.points(Point(0.0, 0.0), Point(1.0, 0.0))
>>> line.is_defined()  # True

Methods

apply_transformation

Apply a transformation to the line in place.

as_cone

Convert the object to a cone.

as_ellipsoid

Convert the object to an ellipsoid.

as_line

Convert the object to a line.

as_line_string

Convert the object to a line string.

as_plane

Convert the object to a plane.

as_point

Convert the object to a point.

as_point_set

Convert the object to a point set.

as_polygon

Convert the object to a polygon.

as_pyramid

Convert the object to a pyramid.

as_ray

Convert the object to a ray.

as_segment

Convert the object to a segment.

as_sphere

Convert the object to a sphere.

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.

intersection_with

Compute the intersection of the line with a plane.

intersects

Overloaded function.

is_cone

Check if the object is a cone.

is_defined

Check if the line is defined.

is_ellipsoid

Check if the object is an ellipsoid.

is_line

Check if the object is a line.

is_line_string

Check if the object is a line string.

is_plane

Check if the object is a plane.

is_point

Check if the object is a point.

is_point_set

Check if the object is a point set.

is_polygon

Check if the object is a polygon.

is_pyramid

Check if the object is a pyramid.

is_ray

Check if the object is a ray.

is_segment

Check if the object is a segment.

is_sphere

Check if the object is a sphere.

points

Create a line passing through two points.

undefined

Create an undefined line.

apply_transformation(
self: ostk.mathematics.geometry.d3.object.Line,
transformation: ostk::mathematics::geometry::d3::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)
as_cone(
self: ostk.mathematics.geometry.d3.Object,
) ostk::mathematics::geometry::d3::object::Cone

Convert the object to a cone.

Returns:

The cone.

Return type:

Cone

as_ellipsoid(
self: ostk.mathematics.geometry.d3.Object,
) ostk::mathematics::geometry::d3::object::Ellipsoid

Convert the object to an ellipsoid.

Returns:

The ellipsoid.

Return type:

Ellipsoid

as_line(
self: ostk.mathematics.geometry.d3.Object,
) ostk::mathematics::geometry::d3::object::Line

Convert the object to a line.

Returns:

The line.

Return type:

Line

as_line_string(
self: ostk.mathematics.geometry.d3.Object,
) ostk::mathematics::geometry::d3::object::LineString

Convert the object to a line string.

Returns:

The line string.

Return type:

LineString

as_plane(
self: ostk.mathematics.geometry.d3.Object,
) ostk::mathematics::geometry::d3::object::Plane

Convert the object to a plane.

Returns:

The plane.

Return type:

Plane

as_point(
self: ostk.mathematics.geometry.d3.Object,
) ostk::mathematics::geometry::d3::object::Point

Convert the object to a point.

Returns:

The point.

Return type:

Point

as_point_set(
self: ostk.mathematics.geometry.d3.Object,
) ostk::mathematics::geometry::d3::object::PointSet

Convert the object to a point set.

Returns:

The point set.

Return type:

PointSet

as_polygon(
self: ostk.mathematics.geometry.d3.Object,
) ostk::mathematics::geometry::d3::object::Polygon

Convert the object to a polygon.

Returns:

The polygon.

Return type:

Polygon

as_pyramid(
self: ostk.mathematics.geometry.d3.Object,
) ostk::mathematics::geometry::d3::object::Pyramid

Convert the object to a pyramid.

Returns:

The pyramid.

Return type:

Pyramid

as_ray(
self: ostk.mathematics.geometry.d3.Object,
) ostk::mathematics::geometry::d3::object::Ray

Convert the object to a ray.

Returns:

The ray.

Return type:

Ray

as_segment(
self: ostk.mathematics.geometry.d3.Object,
) ostk::mathematics::geometry::d3::object::Segment

Convert the object to a segment.

Returns:

The segment.

Return type:

Segment

as_sphere(
self: ostk.mathematics.geometry.d3.Object,
) ostk::mathematics::geometry::d3::object::Sphere

Convert the object to a sphere.

Returns:

The sphere.

Return type:

Sphere

contains(*args, **kwargs)

Overloaded function.

  1. contains(self: ostk.mathematics.geometry.d3.object.Line, point: ostk.mathematics.geometry.d3.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.

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

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

    Args:

    point_set (PointSet): The point set to check.

    Returns:

    bool: True if the line contains all points.

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

Calculate the distance from the line to a point.

Parameters:

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

Returns:

The distance 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.d3.object.Line,
) numpy.ndarray[numpy.float64[3, 1]]

Get the direction vector of the line.

Returns:

The direction vector.

Return type:

numpy.ndarray

Example

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

Get the origin point of the line.

Returns:

The origin point.

Return type:

Point

Example

>>> line = Line.points(Point(0.0, 0.0), Point(1.0, 0.0))
>>> origin = line.get_origin()  # Point(0.0, 0.0, 0.0)
intersection_with(
self: ostk.mathematics.geometry.d3.object.Line,
plane: ostk::mathematics::geometry::d3::object::Plane,
) ostk::mathematics::geometry::d3::Intersection

Compute the intersection of the line with a plane.

Parameters:

plane (Plane) -- The plane to intersect with.

Returns:

The intersection result.

Return type:

Intersection

Example

>>> line = Line.points(Point(0.0, 0.0), Point(1.0, 0.0))
>>> plane = Plane(Point(1.0, 0.0, 0.0), Vector3d(0.0, 0.0, 1.0))
>>> intersection = line.intersection_with(plane)
>>> intersection.get_point()  # Point(1.0, 0.0, 0.0)
intersects(*args, **kwargs)

Overloaded function.

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

    Check if the line intersects a point.

    Args:

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

    Returns:

    bool: True if the line intersects the point.

    Example:
    >>> line = Line.points(Point(0.0, 0.0), Point(1.0, 0.0))
    >>> line.intersects(Point(0.5, 0.5))  # True
    
  2. intersects(self: ostk.mathematics.geometry.d3.object.Line, plane: ostk::mathematics::geometry::d3::object::Plane) -> bool

    Check if the line intersects a plane.

    Args:

    plane (Plane): The plane to check intersection with.

    Returns:

    bool: True if the line intersects the plane.

    Example:
    >>> line = Line.points(Point(0.0, 0.0), Point(1.0, 0.0))
    >>> plane = Plane(Point(1.0, 0.0, 0.0), Vector3d(0.0, 0.0, 1.0))
    >>> line.intersects(plane)  # True
    
  3. intersects(self: ostk.mathematics.geometry.d3.object.Line, sphere: ostk::mathematics::geometry::d3::object::Sphere) -> bool

    Check if the line intersects a sphere.

    Args:

    sphere (Sphere): The sphere to check intersection with.

    Returns:

    bool: True if the line intersects the sphere.

    Example:
    >>> line = Line.points(Point(0.0, 0.0), Point(1.0, 0.0))
    >>> sphere = Sphere(Point(1.0, 0.0, 0.0), 1.0)
    >>> line.intersects(sphere)  # True
    
  4. intersects(self: ostk.mathematics.geometry.d3.object.Line, ellipsoid: ostk::mathematics::geometry::d3::object::Ellipsoid) -> bool

    Check if the line intersects an ellipsoid.

    Args:

    ellipsoid (Ellipsoid): The ellipsoid to check intersection with.

    Returns:

    bool: True if the line intersects the ellipsoid.

    Example:
    >>> line = Line.points(Point(0.0, 0.0), Point(1.0, 0.0))
    >>> ellipsoid = Ellipsoid(Point(2.0, 0.0, 0.0), 1.0, 1.0, 1.0)
    >>> line.intersects(ellipsoid)  # True
    
is_cone(self: ostk.mathematics.geometry.d3.Object) bool

Check if the object is a cone.

Returns:

True if the object is a cone.

Return type:

bool

is_defined(self: ostk.mathematics.geometry.d3.object.Line) bool

Check if the line is defined.

Returns:

True if the line is defined.

Return type:

bool

Example

>>> line = Line.points(Point(0.0, 0.0), Point(1.0, 0.0))
>>> line.is_defined()  # True
is_ellipsoid(self: ostk.mathematics.geometry.d3.Object) bool

Check if the object is an ellipsoid.

Returns:

True if the object is an ellipsoid.

Return type:

bool

is_line(self: ostk.mathematics.geometry.d3.Object) bool

Check if the object is a line.

Returns:

True if the object is a line.

Return type:

bool

is_line_string(self: ostk.mathematics.geometry.d3.Object) bool

Check if the object is a line string.

Returns:

True if the object is a line string.

Return type:

bool

is_plane(self: ostk.mathematics.geometry.d3.Object) bool

Check if the object is a plane.

Returns:

True if the object is a plane.

Return type:

bool

is_point(self: ostk.mathematics.geometry.d3.Object) bool

Check if the object is a point.

Returns:

True if the object is a point.

Return type:

bool

is_point_set(self: ostk.mathematics.geometry.d3.Object) bool

Check if the object is a point set.

Returns:

True if the object is a point set.

Return type:

bool

is_polygon(self: ostk.mathematics.geometry.d3.Object) bool

Check if the object is a polygon.

Returns:

True if the object is a polygon.

Return type:

bool

is_pyramid(self: ostk.mathematics.geometry.d3.Object) bool

Check if the object is a pyramid.

Returns:

True if the object is a pyramid.

Return type:

bool

is_ray(self: ostk.mathematics.geometry.d3.Object) bool

Check if the object is a ray.

Returns:

True if the object is a ray.

Return type:

bool

is_segment(self: ostk.mathematics.geometry.d3.Object) bool

Check if the object is a segment.

Returns:

True if the object is a segment.

Return type:

bool

is_sphere(self: ostk.mathematics.geometry.d3.Object) bool

Check if the object is a sphere.

Returns:

True if the object is a sphere.

Return type:

bool

static points(
first_point: ostk.mathematics.geometry.d3.object.Point,
second_point: ostk.mathematics.geometry.d3.object.Point,
) ostk.mathematics.geometry.d3.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)
>>> line.is_defined()  # True
static undefined() ostk.mathematics.geometry.d3.object.Line

Create an undefined line.

Returns:

An undefined line.

Return type:

Line

Example

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