pub struct Segment(pub Point, pub Point);Expand description
線分(2次元平面)
Tuple Fields§
§0: Point§1: PointImplementations§
Source§impl Segment
impl Segment
Sourcepub fn has_intersection(&self, other: &Self) -> bool
pub fn has_intersection(&self, other: &Self) -> bool
2つの線分が衝突しているかどうかを判定する
Sourcepub fn cross_point(&self, other: &Self) -> Option<Point>
pub fn cross_point(&self, other: &Self) -> Option<Point>
2つの線分の交点を求める
戻り値
- 2つの線分が点
xで交わるとき → Some(x) - 2つの線分が交点を持たないとき → None
Sourcepub fn dist_point(&self, p: Point) -> f64
pub fn dist_point(&self, p: Point) -> f64
点pと線分の距離を求める
Sourcepub fn dist_segment(&self, other: &Self) -> f64
pub fn dist_segment(&self, other: &Self) -> f64
線分同士の距離を求める
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 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