diff -r edb95d2b83cc -r d2acaaddd9af src/sets.rs --- a/src/sets.rs Sun Nov 10 09:02:57 2024 -0500 +++ b/src/sets.rs Tue Dec 31 09:12:43 2024 -0500 @@ -59,15 +59,19 @@ /// vector and $t$ the offset. /// /// `U` is the element type, `F` the floating point number type, and `A` the type of the -/// orthogonal (dual) vectors. They need implement [`Dot`]. +/// orthogonal (dual) vectors. They need implement [`Dot`]. #[derive(Clone,Copy,Debug,Serialize,Eq,PartialEq)] -pub struct Halfspace where A : Dot, F : Float { +pub struct Halfspace +where A : Dot + for<'a> Dot<&'a U>, + F : Float { pub orthogonal : A, pub offset : F, _phantom : PhantomData, } -impl Halfspace where A : Dot, F : Float { +impl Halfspace +where A : Dot + for<'a> Dot<&'a U>, + F : Float { #[inline] pub fn new(orthogonal : A, offset : F) -> Self { Halfspace{ orthogonal : orthogonal, offset : offset, _phantom : PhantomData } @@ -77,7 +81,7 @@ /// Trait for generating a halfspace spanned by another set `Self` of elements of type `U`. pub trait SpannedHalfspace where F : Float { /// Type of the orthogonal vector describing the halfspace. - type A : Dot; + type A : Dot + for<'a> Dot<&'a U>; /// Returns the halfspace spanned by this set. fn spanned_halfspace(&self) -> Halfspace; } @@ -103,7 +107,9 @@ } } -impl Set for Halfspace where A : Dot, F : Float { +impl Set for Halfspace +where A : Dot + for<'a> Dot<&'a U>, + F : Float { #[inline] fn contains(&self, item : &U) -> bool { self.orthogonal.dot(item) >= self.offset @@ -111,10 +117,14 @@ } /// Polygons defined by `N` `Halfspace`s. -#[derive(Clone,Copy,Debug,Eq,PartialEq)] -pub struct NPolygon(pub [Halfspace; N]) where A : Dot, F : Float; +#[derive(Clone,Debug,Eq,PartialEq)] +pub struct NPolygon(pub [Halfspace; N]) +where A : Dot + for<'a> Dot<&'a U>, + F : Float; -impl Set for NPolygon where A : Dot, F : Float { +impl Set for NPolygon +where A : Dot + for<'a> Dot<&'a U>, + F : Float { fn contains(&self, item : &U) -> bool { self.0.iter().all(|halfspace| halfspace.contains(item)) }