pub struct Line {
pub from: V2,
pub to: V2,
}Expand description
A line defined by two points. Can represent both finite line segments and infinite lines.
Fields§
§from: V2§to: V2Implementations§
Source§impl Line
impl Line
pub fn new(from: V2, to: V2) -> Self
Sourcepub fn offset_right(&self, distance: f32) -> Self
pub fn offset_right(&self, distance: f32) -> Self
Returns a new line offset to the right by the given distance.
“Right” is determined by the orthogonal vector to the right of the line’s direction.
Sourcepub fn project(&self, point: &V2) -> V2
pub fn project(&self, point: &V2) -> V2
Projects a point onto the infinite line defined by this line segment.
Sourcepub fn point_relation(&self, point: &V2) -> PointLineRelation
pub fn point_relation(&self, point: &V2) -> PointLineRelation
Determines the position of a point relative to this line.
Sourcepub fn intersection(&self, other: &Line) -> LineIntersection
pub fn intersection(&self, other: &Line) -> LineIntersection
Checks for an intersection between this line segment and another.
For infinite lines, see Self::intersection_as_inf_lines.
Sourcepub fn intersection_as_inf_lines(&self, other: &Line) -> LineIntersection
pub fn intersection_as_inf_lines(&self, other: &Line) -> LineIntersection
Checks for an intersection between this line and another, treating both as infinite lines.
For line segments, see Self::intersection.
Sourcepub fn closest_point_on_infinite_line(&self, point: &V2) -> V2
pub fn closest_point_on_infinite_line(&self, point: &V2) -> V2
Returns the closest point on the infinite line to the given point.
For line segments, see Self::closest_point.
Sourcepub fn closest_point(&self, point: &V2) -> V2
pub fn closest_point(&self, point: &V2) -> V2
Returns the closest point on the line segment to the given point.
For infinite lines, see Self::closest_point_on_infinite_line.
Sourcepub fn intersect_multiple_sorted_by_dist(
&self,
line_segments: &[Line],
) -> Vec<V2>
pub fn intersect_multiple_sorted_by_dist( &self, line_segments: &[Line], ) -> Vec<V2>
Returns all intersections of this line with the given line segments, sorted by distance from self.from.
Trait Implementations§
impl Copy for Line
impl StructuralPartialEq for Line
Auto Trait Implementations§
impl Freeze for Line
impl RefUnwindSafe for Line
impl Send for Line
impl Sync for Line
impl Unpin for Line
impl UnwindSafe for Line
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more