//! Set all the weights void Weight::set_weights(algebra::VectorKD w) { IMP_USAGE_CHECK(static_cast<int>(w.get_dimension()) == get_number_of_states(), "Out of range"); for (int i = 0; i < get_number_of_states(); ++i) { get_particle()->set_value(get_weight_key(i), w[i]); } }
double min_distance_to_rectangle(const algebra::VectorKD& p, const CGAL::Kd_tree_rectangle<TreeTraits>& b) const { double distance(0.0); for (unsigned int i=0; i< p.get_dimension(); ++i) { double h = p[i]; if (h < b.min_coord(i)) distance += base::square(b.min_coord(i)-h); if (h > b.max_coord(i)) distance += base::square(h-b.max_coord(i)); } return distance; }
double max_distance_to_rectangle(const algebra::VectorKD& p, const CGAL::Kd_tree_rectangle<TreeTraits>& b) const { double d=0.0; for (unsigned int i=0; i< p.get_dimension(); ++i) { double h = p[i]; double di = (h >= (b.min_coord(i)+b.max_coord(i))/2.0) ? base::square(h-b.min_coord(i)) : base::square(b.max_coord(i)-h); d+=di; } return d; }