pub struct Line<T: CoordNum = f64> {
    pub start: Coord<T>,
    pub end: Coord<T>,
}Expand description
Fields§
§start: Coord<T>§end: Coord<T>Implementations§
Source§impl<T: CoordNum> Line<T>
 
impl<T: CoordNum> Line<T>
Sourcepub fn new<C>(start: C, end: C) -> Self
 
pub fn new<C>(start: C, end: C) -> Self
Creates a new line segment.
§Examples
use geo_types::{coord, Line};
let line = Line::new(coord! { x: 0., y: 0. }, coord! { x: 1., y: 2. });
assert_eq!(line.start, coord! { x: 0., y: 0. });
assert_eq!(line.end, coord! { x: 1., y: 2. });Sourcepub fn dx(&self) -> T
 
pub fn dx(&self) -> T
Calculate the difference in ‘x’ components (Δx).
Equivalent to:
line.end.x - line.start.xSourcepub fn dy(&self) -> T
 
pub fn dy(&self) -> T
Calculate the difference in ‘y’ components (Δy).
Equivalent to:
line.end.y - line.start.ySourcepub fn slope(&self) -> T
 
pub fn slope(&self) -> T
Calculate the slope (Δy/Δx).
Equivalent to:
line.dy() / line.dx()Note that:
Line::new(a, b).slope() == Line::new(b, a).slope()Sourcepub fn determinant(&self) -> T
 
pub fn determinant(&self) -> T
Calculate the determinant of the line.
Equivalent to:
line.start.x * line.end.y - line.start.y * line.end.xNote that:
Line::new(a, b).determinant() == -Line::new(b, a).determinant()pub fn start_point(&self) -> Point<T>
pub fn end_point(&self) -> Point<T>
pub fn points(&self) -> (Point<T>, Point<T>)
Trait Implementations§
Source§impl<'de, T> Deserialize<'de> for Line<T>where
    T: Deserialize<'de> + CoordNum,
 
impl<'de, T> Deserialize<'de> for Line<T>where
    T: Deserialize<'de> + CoordNum,
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
    __D: Deserializer<'de>,
 
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
    __D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl<T: CoordNum> TryFrom<Geometry<T>> for Line<T>
Convert a Geometry enum into its inner type.
 
impl<T: CoordNum> TryFrom<Geometry<T>> for Line<T>
Convert a Geometry enum into its inner type.
Fails if the enum case does not match the type you are trying to convert it to.
impl<T: Copy + CoordNum> Copy for Line<T>
impl<T: Eq + CoordNum> Eq for Line<T>
impl<T: CoordNum> StructuralPartialEq for Line<T>
Auto Trait Implementations§
impl<T> Freeze for Line<T>where
    T: Freeze,
impl<T> RefUnwindSafe for Line<T>where
    T: RefUnwindSafe,
impl<T> Send for Line<T>where
    T: Send,
impl<T> Sync for Line<T>where
    T: Sync,
impl<T> Unpin for Line<T>where
    T: Unpin,
impl<T> UnwindSafe for Line<T>where
    T: UnwindSafe,
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