use alga::general::{Field, Real, MeetSemilattice, JoinSemilattice, Lattice}; use alga::linear::{AffineSpace, EuclideanSpace}; use core::{ColumnVector, Scalar}; use core::dimension::{DimName, U1}; use core::storage::OwnedStorage; use core::allocator::OwnedAllocator; use geometry::PointBase; impl AffineSpace for PointBase where N: Scalar + Field, S: OwnedStorage, S::Alloc: OwnedAllocator { type Translation = ColumnVector; } impl EuclideanSpace for PointBase where N: Real, S: OwnedStorage, S::Alloc: OwnedAllocator { type Coordinates = ColumnVector; type Real = N; #[inline] fn origin() -> Self { Self::origin() } #[inline] fn coordinates(&self) -> Self::Coordinates { self.coords.clone() } #[inline] fn from_coordinates(coords: Self::Coordinates) -> Self { Self::from_coordinates(coords) } #[inline] fn scale_by(&self, n: N) -> Self { self * n } } /* * * Ordering * */ impl MeetSemilattice for PointBase where N: Scalar + MeetSemilattice, S: OwnedStorage, S::Alloc: OwnedAllocator { #[inline] fn meet(&self, other: &Self) -> Self { PointBase::from_coordinates(self.coords.meet(&other.coords)) } } impl JoinSemilattice for PointBase where N: Scalar + JoinSemilattice, S: OwnedStorage, S::Alloc: OwnedAllocator { #[inline] fn join(&self, other: &Self) -> Self { PointBase::from_coordinates(self.coords.join(&other.coords)) } } impl Lattice for PointBase where N: Scalar + Lattice, S: OwnedStorage, S::Alloc: OwnedAllocator { #[inline] fn meet_join(&self, other: &Self) -> (Self, Self) { let (meet, join) = self.coords.meet_join(&other.coords); (PointBase::from_coordinates(meet), PointBase::from_coordinates(join)) } }