pub struct RawLine {
pub points: [RawPoint; 2],
}Expand description
A straight line segment between two RawPoints.
Fields§
§points: [RawPoint; 2]The two end points of the segment.
Implementations§
Source§impl RawLine
impl RawLine
Sourcepub fn distance_to_point(self, point: RawPoint) -> f32
pub fn distance_to_point(self, point: RawPoint) -> f32
Returns the Euclidean distance from point to the closest point on
this segment.
The closest point is the perpendicular projection of point onto the
segment’s supporting line, clamped to the segment itself; for a
zero-length segment it is simply the distance to the endpoint.
§Examples
use egui_map::map::objects::{RawLine, RawPoint};
let line = RawLine::new(RawPoint::new(0.0, 0.0), RawPoint::new(10.0, 0.0));
assert_eq!(line.distance_to_point(RawPoint::new(5.0, 3.0)), 3.0);
// Beyond the end of the segment, the endpoint is the closest point.
assert_eq!(line.distance_to_point(RawPoint::new(14.0, 0.0)), 4.0);Trait Implementations§
impl Copy for RawLine
Auto Trait Implementations§
impl Freeze for RawLine
impl RefUnwindSafe for RawLine
impl Send for RawLine
impl Sync for RawLine
impl Unpin for RawLine
impl UnsafeUnpin for RawLine
impl UnwindSafe for RawLine
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
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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> ⓘ
Converts
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> ⓘ
Converts
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