pub use crate::shapelib;
pub use crate::slotmap_slot_idx::*;
pub use crate::spec::*;
+pub use crate::spec::pos_traits::*;
pub use crate::spec::piece_specs::{FaceColourSpecs, SimpleCommon};
pub use crate::sse;
pub use crate::toml_de;
use std::ops::{Add,Sub,Mul,Neg};
use crate::prelude::*;
+ pub trait Mean { fn mean(&self, other: &Self) -> Self; }
+
impl<T:CheckedArith> Add<PosC<T>> for PosC<T> {
type Output = Result<Self, CoordinateOverflow>;
#[throws(CoordinateOverflow)]
}
}
+ impl<T> Mean for PosC<T> where T: Mean + Debug {
+ fn mean(&self, other: &Self) -> Self where T: Mean {
+ PosC::try_from_iter_2(
+ izip!(&self.0, &other.0)
+ .map(|(a,b)| Ok::<_,Void>(a.mean(b)))
+ ).unwrap_or_else(|v| match v { })
+ }
+ }
+
impl PosC<Coord> {
pub fn promote(&self) -> PosC<f64> { self.map(|v| v as f64) }
}
}
}
+ impl<T> AreaC<T> where T: Mean + Debug {
+ pub fn middle(&self) -> PosC<T> {
+ Mean::mean(&self.0[0],
+ &self.0[1])
+ }
+ }
+
#[test]
fn empty_area() {
let empty = Area::empty();