Advertisement
Guest User

Untitled

a guest
Dec 17th, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Rust 1.35 KB | None | 0 0
  1. fn classify_points(points: &mut Vec<Point>, starting_point: [f64; 3]) {
  2.     // Create a 3D KdTree
  3.     let dimensions = 3;
  4.     let mut kdtree: KdTree<TreePoint, _> = KdTree::new(dimensions);
  5.  
  6.     // add all the points to the tree
  7.     for point in points.iter() {
  8.         // TODO: find top_left most point
  9.         if point.x == 438000.12 && point.y == 4462999.95 {
  10.             kdtree.add([point.x, point.y, point.z], TreePoint(point, true)).unwrap();
  11.         }
  12.         kdtree.add([point.x, point.y, point.z], TreePoint(point, false)).unwrap();
  13.     }
  14.  
  15.     // study from one point to the next, classifying what we can as we go
  16.     classify_ground(kdtree, starting_point);
  17. }
  18.  
  19. fn classify_ground<T, U>(kdtree: KdTree<U,U>, starting_point: [f64; 3]) where U: std::convert::AsRef<[f64]> {
  20.     // find all points within proper slope to be considered "ground"
  21.     let nearest = kdtree.nearest(&starting_point, 15, &squared_euclidean).unwrap();
  22.     // only take interest in the points that are within 1.5m and have yet to be classified
  23.     for n in &nearest {
  24.         if n.0 <= 1.5 && (n.1).1 {
  25.             // check point slope from "starting_point", if under a value, it is a new ground;
  26.             // add it to the list of "recursive calls to make"
  27.         }
  28.     }
  29.     // store those point values
  30.     unsafe {
  31.         GROUND_CLASSIFIED_COUNT += 1;
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement