[−][src]Struct fart_2d_geom::Line
A line between two points.
Fields
a: TypedPoint2D<T, U>
The first point.
b: TypedPoint2D<T, U>
The second point.
Methods
impl<T, U> Line<T, U> where
T: Copy + Num + PartialOrd,
[src]
T: Copy + Num + PartialOrd,
pub fn new(a: TypedPoint2D<T, U>, b: TypedPoint2D<T, U>) -> Line<T, U>
[src]
Create a new line between the given points.
pub fn relative_direction_of(
&self,
point: TypedPoint2D<T, U>
) -> RelativeDirection
[src]
&self,
point: TypedPoint2D<T, U>
) -> RelativeDirection
Get the direction of the point relative to this line.
pub fn is_left(&self, point: TypedPoint2D<T, U>) -> bool
[src]
Is the given point on the left of this line?
use euclid::{point2, UnknownUnit}; use fart_2d_geom::{line, Line}; let l: Line<i32, UnknownUnit> = line(point2(0, 0), point2(1, 1)); assert!(l.is_left(point2(0, 1))); assert!(!l.is_left(point2(1, 0))); // Collinear points are not considered on the left of the line. See // also `is_left_or_collinear`. assert!(!l.is_left(point2(2, 2)));
pub fn is_left_or_collinear(&self, point: TypedPoint2D<T, U>) -> bool
[src]
Is the given point on the left of this line or collinear with it?
use euclid::{point2, UnknownUnit}; use fart_2d_geom::{line, Line}; let l: Line<i32, UnknownUnit> = line(point2(0, 0), point2(1, 1)); assert!(l.is_left_or_collinear(point2(0, 1))); assert!(l.is_left_or_collinear(point2(2, 2))); assert!(!l.is_left_or_collinear(point2(1, 0)));
pub fn is_collinear(&self, point: TypedPoint2D<T, U>) -> bool
[src]
Is the given point collinear with this line?
use euclid::{point2, UnknownUnit}; use fart_2d_geom::{line, Line}; let l: Line<i32, UnknownUnit> = line(point2(0, 0), point2(1, 1)); assert!(l.is_collinear(point2(2, 2))); assert!(!l.is_collinear(point2(0, 1))); assert!(!l.is_collinear(point2(1, 0)));
pub fn is_right(&self, point: TypedPoint2D<T, U>) -> bool
[src]
Is the given point on the right of this line?
use euclid::{point2, UnknownUnit}; use fart_2d_geom::{line, Line}; let l: Line<i32, UnknownUnit> = line(point2(0, 0), point2(1, 1)); assert!(l.is_right(point2(1, 0))); assert!(!l.is_right(point2(0, 1))); // Collinear points are not considered on the right of the line. See // also `is_right_or_collinear`. assert!(!l.is_right(point2(2, 2)));
pub fn is_right_or_collinear(&self, point: TypedPoint2D<T, U>) -> bool
[src]
Is the given point on the right of this line or collinear with it?
use euclid::{point2, UnknownUnit}; use fart_2d_geom::{line, Line}; let l: Line<i32, UnknownUnit> = line(point2(0, 0), point2(1, 1)); assert!(l.is_right_or_collinear(point2(1, 0))); assert!(l.is_right_or_collinear(point2(2, 2))); assert!(!l.is_right_or_collinear(point2(0, 1)));
pub fn is_on(&self, point: TypedPoint2D<T, U>) -> bool
[src]
Is the given point on this line segment? That is, not just collinear,
but also between self.a
and self.b
?
use euclid::{point2, UnknownUnit}; use fart_2d_geom::{line, Line}; let l: Line<i32, UnknownUnit> = line(point2(0, 0), point2(2, 2)); assert!(l.is_on(point2(1, 1))); assert!(!l.is_on(point2(0, 1))); assert!(!l.is_on(point2(1, 0))); // Inclusive of the line segment's boundaries. assert!(l.is_on(l.a)); assert!(l.is_on(l.b)); // Does not include collinear-but-not-between points. assert!(!l.is_on(point2(3, 3)));
pub fn intersects(&self, other: &Line<T, U>) -> bool
[src]
Does this line segment (properly) intersect with the other line segment?
use euclid::{point2, UnknownUnit}; use fart_2d_geom::{line, Line}; assert!( line::<i32, UnknownUnit>(point2(0, 0), point2(1, 1)) .intersects(&line(point2(0, 1), point2(1, 0))) ); assert!( !line::<i32, UnknownUnit>(point2(0, 0), point2(1, 1)) .intersects(&line(point2(1, 0), point2(2, -1))) ); // If any end points from one line segment land on the other line // segment, `false` is returned because that is not proper intersection. assert!( !line::<i32, UnknownUnit>(point2(0, 0), point2(2, 2)) .intersects(&line(point2(1, 1), point2(2, 0))) );
pub fn improperly_intersects(&self, other: &Line<T, U>) -> bool
[src]
Does this line segment improperly intersect with the other line segment?
use euclid::{point2, UnknownUnit}; use fart_2d_geom::{line, Line}; assert!( line::<i32, UnknownUnit>(point2(0, 0), point2(1, 1)) .improperly_intersects(&line(point2(0, 1), point2(1, 0))) ); assert!( !line::<i32, UnknownUnit>(point2(0, 0), point2(1, 1)) .improperly_intersects(&line(point2(1, 0), point2(2, -1))) ); // If any end points from one line segment land on the other line // segment, `true` is still returned. assert!( line::<i32, UnknownUnit>(point2(0, 0), point2(2, 2)) .improperly_intersects(&line(point2(1, 1), point2(2, 0))) );
Trait Implementations
impl<T: Copy, U: Copy> Copy for Line<T, U>
[src]
impl<T: PartialEq, U: PartialEq> PartialEq<Line<T, U>> for Line<T, U>
[src]
impl<T: Clone, U: Clone> Clone for Line<T, U>
[src]
fn clone(&self) -> Line<T, U>
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl<T: Eq, U: Eq> Eq for Line<T, U>
[src]
impl<T: Debug, U: Debug> Debug for Line<T, U>
[src]
impl<T: Hash, U: Hash> Hash for Line<T, U>
[src]
Auto Trait Implementations
impl<T, U> Send for Line<T, U> where
T: Send,
U: Send,
T: Send,
U: Send,
impl<T, U> Sync for Line<T, U> where
T: Sync,
U: Sync,
T: Sync,
U: Sync,
Blanket Implementations
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
impl<T> From for T
[src]
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,