Skip to content

Instantly share code, notes, and snippets.

@matklad
Created March 5, 2016 19:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matklad/9a541118eb8c5ebd8437 to your computer and use it in GitHub Desktop.
Save matklad/9a541118eb8c5ebd8437 to your computer and use it in GitHub Desktop.
fn A() {
if zdistance > ydistance && zdistance > xdistance {
// "If the z distance is the greatest"
// split on Z
let (split_value, tmp) = find_median_z(pts, start, end, mid);
split_index = tmp;
root_node.split_dimension = Some(Dimension::Z);
root_node.split_value = Some(split_value);
} else if ydistance > xdistance && ydistance > zdistance {
// "If the x distance is the greatest"
// split on Y
let (split_value, tmp) = find_median_y(pts, start, end, mid);
split_index = tmp;
root_node.split_dimension = Some(Dimension::Y);
root_node.split_value = Some(split_value);
} else {
// "If the y distance is the greatest"
// split on X
let (split_value, tmp) = find_median_x(pts, start, end, mid);
split_index = tmp;
root_node.split_dimension = Some(Dimension::X);
root_node.split_value = Some(split_value);
}
}
fn B() {
let (split_dimention, split_value) = if zdistance > ydistance && zdistance > xdistance {
// "If the z distance is the greatest"
// split on Z
let (split_value, tmp) = find_median_z(pts, start, end, mid);
split_index = tmp;
(Dimension::Z, split_value)
} else if ydistance > xdistance && ydistance > zdistance {
// "If the x distance is the greatest"
// split on Y
let (split_value, tmp) = find_median_y(pts, start, end, mid);
split_index = tmp;
(Dimension::Y, split_value)
} else {
// "If the y distance is the greatest"
// split on X
let (split_value, tmp) = find_median_x(pts, start, end, mid);
split_index = tmp;
(Dimension::X, split_value)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment