pub struct Line2 { /* private fields */ }Expand description
An infinite 2D line represented by two sample points.
Implementations§
Source§impl Line2
impl Line2
Sourcepub fn try_new(a: Point2, b: Point2) -> Result<Self, GeometryError>
pub fn try_new(a: Point2, b: Point2) -> Result<Self, GeometryError>
Creates a validated line from two distinct sample points with finite coordinates.
§Errors
Returns GeometryError::NonFiniteComponent when either input point
contains a non-finite coordinate.
Returns GeometryError::IdenticalPoints when a == b.
Sourcepub fn try_from_points(a: Point2, b: Point2) -> Result<Self, GeometryError>
pub fn try_from_points(a: Point2, b: Point2) -> Result<Self, GeometryError>
Creates a validated line from two distinct finite sample points.
§Errors
Returns GeometryError::NonFiniteComponent when either input point
contains a non-finite coordinate.
Returns GeometryError::IdenticalPoints when a == b.
Sourcepub fn try_from_point_direction(
point: Point2,
direction: Vector2,
) -> Result<Self, GeometryError>
pub fn try_from_point_direction( point: Point2, direction: Vector2, ) -> Result<Self, GeometryError>
Creates a validated line from a point and non-zero direction vector.
§Errors
Returns GeometryError::NonFiniteComponent when point or direction
contains a non-finite value.
Returns GeometryError::ZeroDirectionVector when direction is zero.
Sourcepub fn contains_point(self, point: Point2) -> bool
pub fn contains_point(self, point: Point2) -> bool
Returns true when point lies on the infinite line.
Sourcepub fn contains_point_with_tolerance(
self,
point: Point2,
tolerance: f64,
) -> Result<bool, GeometryError>
pub fn contains_point_with_tolerance( self, point: Point2, tolerance: f64, ) -> Result<bool, GeometryError>
Returns true when point lies within tolerance of the line.
§Errors
Returns GeometryError::NonFiniteTolerance when tolerance is NaN
or infinite.
Returns GeometryError::NegativeTolerance when tolerance is negative.
Sourcepub fn try_slope(self) -> Result<Option<f64>, GeometryError>
pub fn try_slope(self) -> Result<Option<f64>, GeometryError>
Returns the slope when both line points contain only finite coordinates.
§Errors
Returns GeometryError::NonFiniteComponent when either point contains
a non-finite coordinate.