use interpolation::Spatial;
use std::num::Float;
pub trait Point<X, Y>: Copy + Clone
where
Y: Spatial,
Y::Scalar: Float,
{
fn x_to_scalar(&self, x: X) -> Y::Scalar;
fn x(&self) -> X;
fn y(&self) -> Y;
#[inline]
fn interpolate(x: X, start: &Self, end: &Self) -> Y {
let x = start.x_to_scalar(x);
let start_x = start.x_to_scalar(start.x());
let end_x = start.x_to_scalar(end.x());
let scalar = (x - start_x) / (end_x - start_x);
end.y().sub(&start.y()).scale(&scalar)
}
}