[−][src]Struct geo::Line
A line segment made up of exactly two Point
s.
Fields
start: Coordinate<T>
end: Coordinate<T>
Methods
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 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> Copy for Line<T> where
T: Copy + CoordinateType,
[src]
T: Copy + CoordinateType,
impl<T> Clone for Line<T> where
T: Clone + CoordinateType,
[src]
T: Clone + CoordinateType,
fn clone(&self) -> Line<T>
[src]
default fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl<T> RTreeObject for Line<T> where
T: Float + RTreeNum,
[src]
T: Float + RTreeNum,
type Envelope = AABB<Point<T>>
The object's envelope type. Usually, AABB will be the right choice. This type also defines the objects dimensionality. Read more
fn envelope(&self) -> <Line<T> as RTreeObject>::Envelope
[src]
impl<T> From<[(T, T); 2]> for Line<T> where
T: CoordinateType,
[src]
T: CoordinateType,
impl<T> From<Line<T>> for Geometry<T> where
T: CoordinateType,
[src]
T: CoordinateType,
impl<T> Debug for Line<T> where
T: Debug + CoordinateType,
[src]
T: Debug + CoordinateType,
impl<T> PointDistance for Line<T> where
T: Float + RTreeNum,
[src]
T: Float + RTreeNum,
fn distance_2(&self, point: &Point<T>) -> T
[src]
default fn contains_point(
&self,
point: &<Self::Envelope as Envelope>::Point
) -> bool
[src]
&self,
point: &<Self::Envelope as Envelope>::Point
) -> bool
Returns true if a point is contained within this object. Read more
impl<T> PartialEq<Line<T>> for Line<T> where
T: PartialEq<T> + CoordinateType,
[src]
T: PartialEq<T> + CoordinateType,
impl<T> Area<T> for Line<T> where
T: CoordinateType,
[src]
T: CoordinateType,
impl<T> BoundingRect<T> for Line<T> where
T: CoordinateType,
[src]
T: CoordinateType,
type Output = Rect<T>
fn bounding_rect(&self) -> Self::Output
[src]
impl<T> Centroid<T> for Line<T> where
T: Float,
[src]
T: Float,
impl<F: Float> ClosestPoint<F, Point<F>> for Line<F>
[src]
fn closest_point(&self, p: &Point<F>) -> Closest<F>
[src]
impl<T> Contains<Point<T>> for Line<T> where
T: Float,
[src]
T: Float,
impl<T> Contains<Line<T>> for Line<T> where
T: Float,
[src]
T: Float,
impl<T> Contains<LineString<T>> for Line<T> where
T: Float,
[src]
T: Float,
fn contains(&self, linestring: &LineString<T>) -> bool
[src]
impl<T> Contains<Line<T>> for LineString<T> where
T: Float,
[src]
T: Float,
impl<T> Contains<Line<T>> for Polygon<T> where
T: Float,
[src]
T: Float,
impl<T> EuclideanDistance<T, Point<T>> for Line<T> where
T: Float,
[src]
T: Float,
fn euclidean_distance(&self, point: &Point<T>) -> T
[src]
Minimum distance from a Line to a Point
impl<T> EuclideanDistance<T, Line<T>> for Point<T> where
T: Float,
[src]
T: Float,
fn euclidean_distance(&self, line: &Line<T>) -> T
[src]
Minimum distance from a Line to a Point
impl<T> EuclideanDistance<T, Line<T>> for LineString<T> where
T: Float + FloatConst + Signed + RTreeNum,
[src]
T: Float + FloatConst + Signed + RTreeNum,
LineString to Line
fn euclidean_distance(&self, other: &Line<T>) -> T
[src]
impl<T> EuclideanDistance<T, LineString<T>> for Line<T> where
T: Float + FloatConst + Signed + RTreeNum,
[src]
T: Float + FloatConst + Signed + RTreeNum,
Line to LineString
fn euclidean_distance(&self, other: &LineString<T>) -> T
[src]
impl<T> EuclideanDistance<T, MultiPolygon<T>> for Line<T> where
T: Float + FloatConst + Signed + RTreeNum,
[src]
T: Float + FloatConst + Signed + RTreeNum,
Line to MultiPolygon distance
fn euclidean_distance(&self, mpolygon: &MultiPolygon<T>) -> T
[src]
impl<T> EuclideanDistance<T, Line<T>> for MultiPolygon<T> where
T: Float + FloatConst + Signed + RTreeNum,
[src]
T: Float + FloatConst + Signed + RTreeNum,
MultiPolygon to Line distance
fn euclidean_distance(&self, other: &Line<T>) -> T
[src]
impl<T> EuclideanDistance<T, Line<T>> for Line<T> where
T: Float + FloatConst + Signed + RTreeNum,
[src]
T: Float + FloatConst + Signed + RTreeNum,
Line to Line distance
fn euclidean_distance(&self, other: &Line<T>) -> T
[src]
impl<T> EuclideanDistance<T, Polygon<T>> for Line<T> where
T: Float + Signed + RTreeNum + FloatConst,
[src]
T: Float + Signed + RTreeNum + FloatConst,
fn euclidean_distance(&self, other: &Polygon<T>) -> T
[src]
impl<T> EuclideanDistance<T, Line<T>> for Polygon<T> where
T: Float + FloatConst + Signed + RTreeNum,
[src]
T: Float + FloatConst + Signed + RTreeNum,
fn euclidean_distance(&self, other: &Line<T>) -> T
[src]
impl<T> EuclideanLength<T, Line<T>> for Line<T> where
T: Float,
[src]
T: Float,
fn euclidean_length(&self) -> T
[src]
impl<T> HaversineLength<T, Line<T>> for Line<T> where
T: Float + FromPrimitive,
[src]
T: Float + FromPrimitive,
fn haversine_length(&self) -> T
[src]
impl<T> Intersects<Point<T>> for Line<T> where
T: Float,
[src]
T: Float,
fn intersects(&self, p: &Point<T>) -> bool
[src]
impl<T> Intersects<Line<T>> for Point<T> where
T: Float,
[src]
T: Float,
fn intersects(&self, line: &Line<T>) -> bool
[src]
impl<T> Intersects<Line<T>> for Line<T> where
T: Float,
[src]
T: Float,
fn intersects(&self, line: &Line<T>) -> bool
[src]
impl<T> Intersects<LineString<T>> for Line<T> where
T: Float,
[src]
T: Float,
fn intersects(&self, linestring: &LineString<T>) -> bool
[src]
impl<T> Intersects<Line<T>> for LineString<T> where
T: Float,
[src]
T: Float,
fn intersects(&self, line: &Line<T>) -> bool
[src]
impl<T> Intersects<Polygon<T>> for Line<T> where
T: Float,
[src]
T: Float,
fn intersects(&self, p: &Polygon<T>) -> bool
[src]
impl<T> Intersects<Line<T>> for Polygon<T> where
T: Float,
[src]
T: Float,
fn intersects(&self, line: &Line<T>) -> bool
[src]
impl<T: CoordinateType, NT: CoordinateType> MapCoords<T, NT> for Line<T>
[src]
impl<T: CoordinateType, NT: CoordinateType> TryMapCoords<T, NT> for Line<T>
[src]
type Output = Line<NT>
fn try_map_coords(
&self,
func: &dyn Fn(&(T, T)) -> Result<(NT, NT), Error>
) -> Result<Self::Output, Error>
[src]
&self,
func: &dyn Fn(&(T, T)) -> Result<(NT, NT), Error>
) -> Result<Self::Output, Error>
impl<T: CoordinateType> MapCoordsInplace<T> for Line<T>
[src]
impl<T> Rotate<T> for Line<T> where
T: Float,
[src]
T: Float,
impl<T> VincentyLength<T, Line<T>> for Line<T> where
T: Float + FromPrimitive,
[src]
T: Float + FromPrimitive,
fn vincenty_length(&self) -> Result<T, FailedToConvergeError>
[src]
The units of the returned value is meters.
Auto Trait Implementations
Blanket Implementations
impl<T, G> RotatePoint for G where
G: MapCoords<T, T, Output = G>,
T: Float,
[src]
G: MapCoords<T, T, Output = G>,
T: Float,
fn rotate_around_point(&Self, T, Point<T>) -> G
[src]
impl<T, G> Translate for G where
G: MapCoords<T, T, Output = G> + MapCoordsInplace<T>,
T: CoordinateType,
[src]
G: MapCoords<T, T, Output = G> + MapCoordsInplace<T>,
T: CoordinateType,
impl<T> From for T
[src]
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, 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>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<P> RTreeObject for P where
P: Point,
[src]
P: Point,
type Envelope = AABB<P>
The object's envelope type. Usually, AABB will be the right choice. This type also defines the objects dimensionality. Read more
fn envelope(&self) -> AABB<P>
[src]
impl<P> PointDistance for P where
P: Point,
[src]
P: Point,
fn distance_2(&self, point: &P) -> <P as Point>::Scalar
[src]
fn contains_point(
&self,
point: &<<P as RTreeObject>::Envelope as Envelope>::Point
) -> bool
[src]
&self,
point: &<<P as RTreeObject>::Envelope as Envelope>::Point
) -> bool