4 |
4 |
5 use crate::types::*; |
5 use crate::types::*; |
6 use crate::loc::Loc; |
6 use crate::loc::Loc; |
7 use crate::sets::{Set,NPolygon,SpannedHalfspace}; |
7 use crate::sets::{Set,NPolygon,SpannedHalfspace}; |
8 use crate::linsolve::*; |
8 use crate::linsolve::*; |
9 use crate::euclidean::Dot; |
9 use crate::euclidean::Euclidean; |
|
10 use crate::instance::Instance; |
10 use super::base::{LocalModel,RealLocalModel}; |
11 use super::base::{LocalModel,RealLocalModel}; |
11 use crate::sets::Cube; |
12 use crate::sets::Cube; |
12 use numeric_literals::replace_float_literals; |
13 use numeric_literals::replace_float_literals; |
13 |
14 |
14 /// Type for simplices of arbitrary dimension `N`. |
15 /// Type for simplices of arbitrary dimension `N`. |
28 (a+b)/2.0 |
29 (a+b)/2.0 |
29 } |
30 } |
30 |
31 |
31 impl<'a, F : Float> Set<Loc<F,1>> for RealInterval<F> { |
32 impl<'a, F : Float> Set<Loc<F,1>> for RealInterval<F> { |
32 #[inline] |
33 #[inline] |
33 fn contains(&self, &Loc([x]) : &Loc<F,1>) -> bool { |
34 fn contains<I : Instance<Loc<F, 1>>>(&self, z : I) -> bool { |
|
35 let &Loc([x]) = z.ref_instance(); |
34 let &[Loc([x0]), Loc([x1])] = &self.0; |
36 let &[Loc([x0]), Loc([x1])] = &self.0; |
35 (x0 < x && x < x1) || (x1 < x && x < x0) |
37 (x0 < x && x < x1) || (x1 < x && x < x0) |
36 } |
38 } |
37 } |
39 } |
38 |
40 |
39 impl<'a, F : Float> Set<Loc<F,2>> for PlanarSimplex<F> { |
41 impl<'a, F : Float> Set<Loc<F,2>> for PlanarSimplex<F> { |
40 #[inline] |
42 #[inline] |
41 fn contains(&self, x : &Loc<F,2>) -> bool { |
43 fn contains<I : Instance<Loc<F, 2>>>(&self, z : I) -> bool { |
42 let &[x0, x1, x2] = &self.0; |
44 let &[x0, x1, x2] = &self.0; |
43 NPolygon([[x0, x1].spanned_halfspace(), |
45 NPolygon([[x0, x1].spanned_halfspace(), |
44 [x1, x2].spanned_halfspace(), |
46 [x1, x2].spanned_halfspace(), |
45 [x2, x0].spanned_halfspace()]).contains(x) |
47 [x2, x0].spanned_halfspace()]).contains(z) |
46 } |
48 } |
47 } |
49 } |
48 |
50 |
49 trait P2Powers { |
51 trait P2Powers { |
50 type Output; |
52 type Output; |