Make bounds have dims size

This commit is contained in:
khmhmm 2021-03-10 17:36:01 +04:00
parent 99e465ba6e
commit 19f516bb11

View File

@ -1,9 +1,9 @@
use num_traits::Float; use num_traits::Float;
use crate::kdtree::KdTreePoint; use crate::kdtree::KdTreePoint;
#[derive(Clone, Copy)] #[derive(Clone)]
pub struct Bounds<F: Float> { pub struct Bounds<F: Float> {
pub bounds: [(F, F); 3], pub bounds: Vec<(F, F)>,
widest_dim: usize, widest_dim: usize,
midvalue_of_widest_dim: F, midvalue_of_widest_dim: F,
@ -12,7 +12,7 @@ pub struct Bounds<F: Float> {
impl<F: Float> Bounds<F> { impl<F: Float> Bounds<F> {
pub fn new_from_points<T: KdTreePoint<F>>(points: &[T]) -> Bounds<F> { pub fn new_from_points<T: KdTreePoint<F>>(points: &[T]) -> Bounds<F> {
let mut bounds = Bounds { let mut bounds = Bounds {
bounds: [(F::zero(), F::zero()), (F::zero(), F::zero()), (F::zero(), F::zero())], bounds: Vec::with_capacity(points[0].dims()),
widest_dim: 0, widest_dim: 0,
midvalue_of_widest_dim: F::zero(), midvalue_of_widest_dim: F::zero(),
}; };