pub struct Segment {
pub l: Point,
pub r: Point,
}Expand description
A line segment between two points where l.x < r.x.
Fields§
§l: PointLeft endpoint (smaller x).
r: PointRight endpoint (larger x).
Implementations§
Source§impl Segment
impl Segment
Sourcepub fn new(l: Point, r: Point) -> Result<Self>
pub fn new(l: Point, r: Point) -> Result<Self>
Create a new segment from left point l to right point r.
§Errors
Returns an error if l == r or l.x >= r.x.
Sourcepub fn approximately_equal(&self, other: &Self) -> bool
pub fn approximately_equal(&self, other: &Self) -> bool
Whether two segments are approximately equal (within relative tolerance 1e-5 on both y-coordinates).
Sourcepub fn compatible(&self, other: &Self) -> bool
pub fn compatible(&self, other: &Self) -> bool
Whether two segments share the same x-range.
Sourcepub fn above(&self, other: &Self) -> Result<bool>
pub fn above(&self, other: &Self) -> Result<bool>
Whether self is strictly above other (both endpoints at
least as high, and not equal).
§Errors
Returns an error if the segments are not compatible.
Sourcepub fn above_eq(&self, other: &Self) -> Result<bool>
pub fn above_eq(&self, other: &Self) -> Result<bool>
Whether self is above or equal to other.
§Errors
Returns an error if the segments are not compatible.
Sourcepub fn intersects(&self, other: &Self) -> Result<bool>
pub fn intersects(&self, other: &Self) -> Result<bool>
Whether two compatible segments intersect.
§Errors
Returns an error if the segments are not compatible.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Segment
impl RefUnwindSafe for Segment
impl Send for Segment
impl Sync for Segment
impl Unpin for Segment
impl UnsafeUnpin for Segment
impl UnwindSafe for Segment
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
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> ⓘ
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