de.biomedical_imaging.edu.wlu.cs.levy.CG.HRect Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of kdtree Show documentation
Show all versions of kdtree Show documentation
KDTree implementation from Simon Levy with modifications to work with double values
The newest version!
// HRect.java : Hyper-Rectangle class supporting KDTree class
//
// Copyright (C) Simon D. Levy 2014
//
// This code is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This code is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this code. If not, see .
// You should also have received a copy of the Parrot Parrot AR.Drone
// Development License and Parrot AR.Drone copyright notice and disclaimer
// and If not, see
//
// and
// .
package de.biomedical_imaging.edu.wlu.cs.levy.CG;
import java.io.Serializable;
class HRect implements Serializable{
protected HPoint min;
protected HPoint max;
protected HRect(int ndims) {
min = new HPoint(ndims);
max = new HPoint(ndims);
}
protected HRect(HPoint vmin, HPoint vmax) {
min = (HPoint)vmin.clone();
max = (HPoint)vmax.clone();
}
protected Object clone() {
return new HRect(min, max);
}
// from Moore's eqn. 6.6
protected HPoint closest(HPoint t) {
HPoint p = new HPoint(t.coord.length);
for (int i=0; i=max.coord[i]) {
p.coord[i] = max.coord[i];
}
else {
p.coord[i] = t.coord[i];
}
}
return p;
}
// used in initial conditions of KDTree.nearest()
protected static HRect infiniteHRect(int d) {
HPoint vmin = new HPoint(d);
HPoint vmax = new HPoint(d);
for (int i=0; i= newmax.coord[i]) return null;
}
return new HRect(newmin, newmax);
}
// currently unused
protected double area () {
double a = 1;
for (int i=0; i