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]],
- point: ostk.mathematics.geometry.d2.object.Point,
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 a transformation to the line in place.
Overloaded function.
Calculate the distance from the line to a point.
Get the direction vector of the line.
Get the origin point of the line.
Check if the line intersects with a point.
Check if the line is defined.
Create a line passing through two points.
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,
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.
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
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( ) 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:
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( ) 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( ) ostk.mathematics.geometry.d2.object.Point ¶
Get the origin point of the line.
- Returns:
The origin point of the line.
- Return type:
Example
>>> line = Line.points(Point(1.0, 2.0), Point(3.0, 4.0)) >>> origin = line.get_origin()
- intersects( ) 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:
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:
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,
Create a line passing through two points.
- Parameters:
- Returns:
A line passing through both points.
- Return type:
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:
Example
>>> undefined_line = Line.undefined() >>> undefined_line.is_defined() # False