ostk.mathematics.geometry.d2.object.LineString¶
- class LineString(
- self: ostk.mathematics.geometry.d2.object.LineString,
- points: list[ostk.mathematics.geometry.d2.object.Point],
Bases:
ObjectCreate a 2D line string from a sequence of points.
- Parameters:
points (list) -- A list of Point objects defining the line string.
Example
>>> points = [Point(0.0, 0.0), Point(1.0, 1.0), Point(2.0, 0.0)] >>> line_string = LineString(points)
Methods
Apply a transformation to the line string in place.
Check if this 2D object contains another object.
Create an empty line string.
Get the point on the line string closest to a given point.
Get the number of points in the line string.
Check if this 2D object intersects with another object.
Check if the line string is defined.
Check if the line string is empty (has no points).
Check if the line string is near another line string.
Convert the line string to a string representation.
- class Format(self: ostk.mathematics.geometry.d2.Object.Format, value: int)¶
Bases:
pybind11_objectMembers:
Undefined
Standard
WKT
- property name¶
- apply_transformation(
- self: ostk.mathematics.geometry.d2.object.LineString,
- transformation: ostk::mathematics::geometry::d2::Transformation,
Apply a transformation to the line string in place.
- Parameters:
transformation (Transformation) -- The transformation to apply.
Example
>>> line_string = LineString(points) >>> transformation = Transformation.translation([1.0, 0.0]) >>> line_string.apply_transformation(transformation)
- 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
- static empty() ostk.mathematics.geometry.d2.object.LineString¶
Create an empty line string.
- Returns:
An empty line string.
- Return type:
Example
>>> empty_line = LineString.empty() >>> empty_line.is_empty() # True
- get_point_closest_to(
- self: ostk.mathematics.geometry.d2.object.LineString,
- point: ostk.mathematics.geometry.d2.object.Point,
Get the point on the line string closest to a given point.
- Parameters:
point (Point) -- The reference point.
- Returns:
The closest point on the line string.
- Return type:
Example
>>> points = [Point(0.0, 0.0), Point(1.0, 1.0), Point(2.0, 0.0)] >>> line_string = LineString(points) >>> closest = line_string.get_point_closest_to(Point(0.5, 0.5))
- get_point_count(self: ostk.mathematics.geometry.d2.object.LineString) int¶
Get the number of points in the line string.
- Returns:
The number of points.
- Return type:
Example
>>> points = [Point(0.0, 0.0), Point(1.0, 1.0), Point(2.0, 0.0)] >>> line_string = LineString(points) >>> line_string.get_point_count() # 3
- 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.LineString) bool¶
Check if the line string is defined.
- Returns:
True if the line string is defined, False otherwise.
- Return type:
Example
>>> points = [Point(0.0, 0.0), Point(1.0, 1.0)] >>> line_string = LineString(points) >>> line_string.is_defined() # True
- is_empty(self: ostk.mathematics.geometry.d2.object.LineString) bool¶
Check if the line string is empty (has no points).
- Returns:
True if the line string is empty, False otherwise.
- Return type:
Example
>>> empty_line = LineString.empty() >>> empty_line.is_empty() # True
- is_near(
- self: ostk.mathematics.geometry.d2.object.LineString,
- line_string: ostk.mathematics.geometry.d2.object.LineString,
- tolerance: ostk.core.type.Real,
- line_string: ostk.mathematics.geometry.d2.object.LineString,
Check if the line string is near another line string.
- Parameters:
line_string (LineString) -- The line string to check.
tolerance (float) -- The tolerance.
- Returns:
True if the line string is near another line string, False otherwise.
- Return type:
Example
>>> line_string = LineString(points) >>> line_string.is_near(LineString(points), 0.1) # True
- to_string(
- self: ostk.mathematics.geometry.d2.object.LineString,
- 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 line string 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 line string.
- Return type:
Example
>>> points = [Point(0.0, 0.0), Point(1.0, 1.0)] >>> line_string = LineString(points) >>> line_string.to_string()