[−][src]Struct geo_types::Line
A line segment made up of exactly two
Coordinate
s.
Semantics
The interior and boundary are defined as with a
LineString
with the two end points.
Fields
start: Coordinate<T>
end: Coordinate<T>
Implementations
impl<T> Line<T> where
T: CoordinateType,
[src]
T: CoordinateType,
pub fn new<C>(start: C, end: C) -> Line<T> where
C: Into<Coordinate<T>>,
[src]
C: Into<Coordinate<T>>,
Creates a new line segment.
Examples
use geo_types::{Coordinate, Line}; let line = Line::new(Coordinate { x: 0., y: 0. }, Coordinate { x: 1., y: 2. }); assert_eq!(line.start, Coordinate { x: 0., y: 0. }); assert_eq!(line.end, Coordinate { x: 1., y: 2. });
pub fn delta(&self) -> Coordinate<T>
[src]
Calculate the difference in coordinates (Δx, Δy).
pub fn dx(&self) -> T
[src]
Calculate the difference in ‘x’ components (Δx).
Equivalent to:
line.end.x - line.start.x
pub fn dy(&self) -> T
[src]
Calculate the difference in ‘y’ components (Δy).
Equivalent to:
line.end.y - line.start.y
pub fn slope(&self) -> T
[src]
Calculate the slope (Δy/Δx).
Equivalent to:
line.dy() / line.dx()
Note that:
Line::new(a, b).slope() == Line::new(b, a).slope()
pub fn determinant(&self) -> T
[src]
Calculate the determinant of the line.
Equivalent to:
line.start.x * line.end.y - line.start.y * line.end.x
Note that:
Line::new(a, b).determinant() == -Line::new(b, a).determinant()
pub fn start_point(&self) -> Point<T>
[src]
pub fn end_point(&self) -> Point<T>
[src]
pub fn points(&self) -> (Point<T>, Point<T>)
[src]
Trait Implementations
impl<T: Clone> Clone for Line<T> where
T: CoordinateType,
[src]
T: CoordinateType,
impl<T: Copy> Copy for Line<T> where
T: CoordinateType,
[src]
T: CoordinateType,
impl<T: Debug> Debug for Line<T> where
T: CoordinateType,
[src]
T: CoordinateType,
impl<T: Eq> Eq for Line<T> where
T: CoordinateType,
[src]
T: CoordinateType,
impl<T: CoordinateType> From<[(T, T); 2]> for Line<T>
[src]
impl<T: CoordinateType> From<Line<T>> for Geometry<T>
[src]
impl<T: Hash> Hash for Line<T> where
T: CoordinateType,
[src]
T: CoordinateType,
pub fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
pub fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl<T: PartialEq> PartialEq<Line<T>> for Line<T> where
T: CoordinateType,
[src]
T: CoordinateType,
impl<T> StructuralEq for Line<T> where
T: CoordinateType,
[src]
T: CoordinateType,
impl<T> StructuralPartialEq for Line<T> where
T: CoordinateType,
[src]
T: CoordinateType,
impl<T> TryFrom<Geometry<T>> for Line<T> where
T: Float,
[src]
T: Float,
Auto Trait Implementations
impl<T> RefUnwindSafe for Line<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<T> Send for Line<T> where
T: Send,
T: Send,
impl<T> Sync for Line<T> where
T: Sync,
T: Sync,
impl<T> Unpin for Line<T> where
T: Unpin,
T: Unpin,
impl<T> UnwindSafe for Line<T> where
T: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,