use super::*;
mod arthmetic;
mod constructors;
mod euclidean;
mod manhattan;
#[cfg_attr(feature = "serde", repr(C), derive(Serialize, Deserialize))]
#[derive(Copy, Clone, PartialEq, Eq, Hash)]
pub struct Point<T> {
pub x: T,
pub y: T,
}
impl<T> Point<T> {
pub fn ref_inner(&self) -> Point<&T> {
Point { x: &self.x, y: &self.y }
}
}
impl<T> Point<T>
where
T: Num + Clone,
{
pub fn norm(&self) -> T
where
T: Float,
{
(self.x.clone() * self.x.clone() + self.y.clone() * self.y.clone()).sqrt()
}
pub fn cross_dot(&self, a: &Self, b: &Self) -> T {
let p = (b.x.clone() - a.x.clone()) * (self.y.clone() - b.y.clone());
let q = (b.y.clone() - a.y.clone()) * (self.x.clone() - b.x.clone());
p - q
}
}