Trait geo::algorithm::line_interpolate_point::LineInterpolatePoint[][src]

pub trait LineInterpolatePoint<F: CoordFloat> {
    type Output;
    fn line_interpolate_point(&self, fraction: F) -> Self::Output;
}

Returns an option of the point that lies a given fraction along the line.

If the given fraction is

  • less than zero (including negative infinity): returns a Some of the starting point
  • greater than one (including infinity): returns a Some of the ending point

If either the fraction is NaN, or any coordinates of the line are not finite, returns None.

Examples

use geo::{LineString, point};
use geo::algorithm::line_interpolate_point::LineInterpolatePoint;

let linestring: LineString<f64> = vec![
    [-1.0, 0.0],
    [0.0, 0.0],
    [0.0, 1.0]
].into();

assert_eq!(linestring.line_interpolate_point(-1.0), Some(point!(x: -1.0, y: 0.0)));
assert_eq!(linestring.line_interpolate_point(0.25), Some(point!(x: -0.5, y: 0.0)));
assert_eq!(linestring.line_interpolate_point(0.5), Some(point!(x: 0.0, y: 0.0)));
assert_eq!(linestring.line_interpolate_point(0.75), Some(point!(x: 0.0, y: 0.5)));
assert_eq!(linestring.line_interpolate_point(2.0), Some(point!(x: 0.0, y: 1.0)));

Associated Types

Loading content...

Required methods

fn line_interpolate_point(&self, fraction: F) -> Self::Output[src]

Loading content...

Implementors

impl<T> LineInterpolatePoint<T> for Line<T> where
    T: CoordFloat
[src]

type Output = Option<Point<T>>

impl<T> LineInterpolatePoint<T> for LineString<T> where
    T: CoordFloat + AddAssign + Debug,
    Line<T>: EuclideanLength<T>,
    LineString<T>: EuclideanLength<T>, 
[src]

type Output = Option<Point<T>>

Loading content...