34 const double ERR = 0.001;
89 for (d = 1; d <
dim; d++) {
91 if (length > max_length) {
96 for (d = 0; d <
dim; d++) {
98 if (
double(bnds.
hi[d] - bnds.
lo[d]) >= (1-
ERR)*max_length) {
101 if (spr > max_spread) {
108 cut_val = (bnds.
lo[cut_dim] + bnds.
hi[cut_dim]) / 2;
120 if (br1 > n/2) n_lo = br1;
121 else if (br2 < n/2) n_lo = br2;
159 for (d = 1; d <
dim; d++) {
161 if (length > max_length) {
166 for (d = 0; d <
dim; d++) {
168 if ((bnds.
hi[d] - bnds.
lo[d]) >= (1-
ERR)*max_length) {
171 if (spr > max_spread) {
178 ANNcoord ideal_cut_val = (bnds.
lo[cut_dim] + bnds.
hi[cut_dim])/2;
181 annMinMax(pa, pidx, n, cut_dim, min, max);
183 if (ideal_cut_val < min)
185 else if (ideal_cut_val > max)
188 cut_val = ideal_cut_val;
208 if (ideal_cut_val < min) n_lo = 1;
209 else if (ideal_cut_val > max) n_lo = n-1;
210 else if (br1 > n/2) n_lo = br1;
211 else if (br2 < n/2) n_lo = br2;
256 for (d = 1; d <
dim; d++) {
258 if (length > max_length) {
266 for (d = 0; d <
dim; d++) {
273 if (spr > max_spread) {
281 for (d = 0; d <
dim; d++) {
283 if (d != cut_dim && length > max_length)
288 ANNcoord lo_cut = bnds.
lo[cut_dim] + small_piece;
289 ANNcoord hi_cut = bnds.
hi[cut_dim] - small_piece;
362 for (d = 1; d <
dim; d++) {
364 if (length > max_length) {
372 for (d = 0; d <
dim; d++) {
379 if (spr > max_spread) {
387 for (d = 0; d <
dim; d++) {
389 if (d != cut_dim && length > max_length)
394 ANNcoord lo_cut = bnds.
lo[cut_dim] + small_piece;
395 ANNcoord hi_cut = bnds.
hi[cut_dim] - small_piece;
397 annMinMax(pa, pidx, n, cut_dim, min, max);
ANNcoord annSpread(ANNpointArray pa, ANNidxArray pidx, int n, int d)
void sl_midpt_split(ANNpointArray pa, ANNidxArray pidx, const ANNorthRect &bnds, int n, int dim, int &cut_dim, ANNcoord &cut_val, int &n_lo)
void sl_fair_split(ANNpointArray pa, ANNidxArray pidx, const ANNorthRect &bnds, int n, int dim, int &cut_dim, ANNcoord &cut_val, int &n_lo)
void annMinMax(ANNpointArray pa, ANNidxArray pidx, int n, int d, ANNcoord &min, ANNcoord &max)
void kd_split(ANNpointArray pa, ANNidxArray pidx, const ANNorthRect &bnds, int n, int dim, int &cut_dim, ANNcoord &cut_val, int &n_lo)
int annMaxSpread(ANNpointArray pa, ANNidxArray pidx, int n, int dim)
const double FS_ASPECT_RATIO
void fair_split(ANNpointArray pa, ANNidxArray pidx, const ANNorthRect &bnds, int n, int dim, int &cut_dim, ANNcoord &cut_val, int &n_lo)
int annSplitBalance(ANNpointArray pa, ANNidxArray pidx, int n, int d, ANNcoord cv)
void annMedianSplit(ANNpointArray pa, ANNidxArray pidx, int n, int d, ANNcoord &cv, int n_lo)
void annPlaneSplit(ANNpointArray pa, ANNidxArray pidx, int n, int d, ANNcoord cv, int &br1, int &br2)
void midpt_split(ANNpointArray pa, ANNidxArray pidx, const ANNorthRect &bnds, int n, int dim, int &cut_dim, ANNcoord &cut_val, int &n_lo)