ostk.mathematics.geometry.d3.object.LineString

class LineString(
self: ostk.mathematics.geometry.d3.object.LineString,
points: list[ostk.mathematics.geometry.d3.object.Point],
)

Bases: Object

A sequence of connected line segments in 3D space.

A LineString is an ordered sequence of points forming a polyline.

Example

>>> points = [Point(0.0, 0.0), Point(1.0, 1.0)]
>>> line_string = LineString(points)
>>> line_string.is_defined()  # True

Construct a line string from an array of points.

Args: points (list[Point]): Array of 3D points defining the line string.

Example: >>> points = [Point(0.0, 0.0), Point(1.0, 1.0)] >>> line_string = LineString(points) >>> line_string.is_defined() # True

Methods

access_point_at

Access a point at a given index.

apply_transformation

Apply a transformation to all points in the line string.

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

Check if this object contains another object.

empty

Create an empty line string.

get_point_closest_to

Get the point in the line string closest to a given point.

get_point_count

Get the number of points in the line string.

intersects

Check if this object intersects another object.

is_cone

Check if the object is a cone.

is_defined

Check if the line string is defined.

is_ellipsoid

Check if the object is an ellipsoid.

is_empty

Check if the line string is empty.

is_line

Check if the object is a line.

is_line_string

Check if the object is a line string.

is_near

Check if another line string is near this one within a tolerance.

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.

segment

Create a line string from a segment.

access_point_at(
self: ostk.mathematics.geometry.d3.object.LineString,
index: int,
) ostk.mathematics.geometry.d3.object.Point

Access a point at a given index.

Parameters:

index (int) -- The index of the point.

Returns:

Reference to the point at the index.

Return type:

Point

Example

>>> points = [Point(0.0, 0.0), Point(1.0, 1.0)]
>>> line_string = LineString(points)
>>> line_string.access_point_at(0)  # Point(0.0, 0.0)
apply_transformation(
self: ostk.mathematics.geometry.d3.object.LineString,
transformation: ostk::mathematics::geometry::d3::Transformation,
) None

Apply a transformation to all points in the line string.

Parameters:

transformation (Transformation) -- The transformation to apply.

Example

>>> points = [Point(0.0, 0.0), Point(1.0, 1.0)]
>>> line_string = LineString(points)
>>> transformation = Transformation.translation([1.0, 0.0])
>>> line_string.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(
self: ostk.mathematics.geometry.d3.Object,
arg0: ostk.mathematics.geometry.d3.Object,
) bool

Check if this object contains another object.

Parameters:

object (Object) -- The object to check containment of.

Returns:

True if this object contains the other object.

Return type:

bool

Example

>>> object = Cone(Point(1.0, 2.0, 3.0), [0.0, 0.0, 1.0], Angle.degrees(30.0))
>>> other_object = Point(1.0, 2.0, 3.1)
>>> object.contains(other_object)  # True
static empty() ostk.mathematics.geometry.d3.object.LineString

Create an empty line string.

Returns:

An empty line string.

Return type:

LineString

Example

>>> line_string = LineString.empty()
>>> line_string.is_empty()  # True
get_point_closest_to(
self: ostk.mathematics.geometry.d3.object.LineString,
point: ostk.mathematics.geometry.d3.object.Point,
) ostk.mathematics.geometry.d3.object.Point

Get the point in the line string closest to a given point.

Parameters:

point (Point) -- The reference point.

Returns:

The closest point in the line string.

Return type:

Point

Example

>>> points = [Point(0.0, 0.0), Point(1.0, 1.0)]
>>> line_string = LineString(points)
>>> line_string.get_point_closest_to(Point(0.5, 0.5))  # Point(0.5, 0.5)
get_point_count(self: ostk.mathematics.geometry.d3.object.LineString) int

Get the number of points in the line string.

Returns:

The number of points.

Return type:

int

Example

>>> points = [Point(0.0, 0.0), Point(1.0, 1.0)]
>>> line_string = LineString(points)
>>> line_string.get_point_count()  # 2
intersects(
self: ostk.mathematics.geometry.d3.Object,
arg0: ostk.mathematics.geometry.d3.Object,
) bool

Check if this object intersects another object.

Parameters:

object (Object) -- The object to check intersection with.

Returns:

True if the objects intersect.

Return type:

bool

Example

>>> object = Cone(Point(1.0, 2.0, 3.0), [0.0, 0.0, 1.0], Angle.degrees(30.0))
>>> other_object = Point(1.0, 2.0, 3.1)
>>> object.intersects(other_object)  # 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.LineString) bool

Check if the line string is defined.

Returns:

True if the line string is defined.

Return type:

bool

Example

>>> points = [Point(0.0, 0.0), Point(1.0, 1.0)]
>>> line_string = LineString(points)
>>> line_string.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_empty(self: ostk.mathematics.geometry.d3.object.LineString) bool

Check if the line string is empty.

Returns:

True if the line string contains no points.

Return type:

bool

Example

>>> line_string = LineString.empty()
>>> line_string.is_empty()  # True
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_near(
self: ostk.mathematics.geometry.d3.object.LineString,
line_string: ostk.mathematics.geometry.d3.object.LineString,
tolerance: ostk.core.type.Real,
) bool

Check if another line string is near this one within a tolerance.

Args: line_string (LineString): The line string to compare against. tolerance (float): The maximum distance for points to be considered near.

Returns: bool: True if the line strings are near each other.

Example: >>> line_string = LineString(points) >>> line_string.is_near(LineString(points), 0.1) # True

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 segment(
segment: ostk.mathematics.geometry.d3.object.Segment,
) ostk.mathematics.geometry.d3.object.LineString

Create a line string from a segment.

Parameters:

segment (Segment) -- The segment to convert.

Returns:

A line string representing the segment.

Return type:

LineString

Example

>>> segment = Segment(Point(0.0, 0.0, 0.0), Point(1.0, 1.0, 1.0))
>>> line_string = LineString.segment(segment)
>>> line_string.is_defined()  # True