0

3D 空間内の別のポイントに最も近いポイントのインデックスを返すメソッドを作成しようとしています。ポイントは KD ツリーに保存され、メソッドのパラメーターであるポイント p と比較しています。メソッドは次のとおりです。

public int NearestPointWithDistance(KDnnTreeNode node, Point p, Double distance){
  int index = -1;
  if(node == null){
     return -1;
  }else{
      double[] point_coordinates = data[node.eltIndex];
      Point q = new Point(point_coordinates[0],point_coordinates[1], point_coordinates[2]);
      if(KDnnTree.distance(p, q) == distance){
             return index;
      }  

      if(node.left != null){
          final int left_child = NearestPointWithDistance(node.left, p, distance);
      }
      if(node.right != null){
          final int right_child = NearestPointWithDistance(node.right, p, distance);
        }
    }
  return index;

}

問題は、同じ距離に複数のポイントが存在する可能性があることです。得られる結果はポイントのインデックスのリストです (以下を参照) が、リストの最初の要素のみが必要です (以下の例では、番号 54510 になります)。

54510
54511
54512
54514
54518
54526
54543
54577
65355
76175
54482
54416
54278
21929
54001
74323 

これが KD ツリーの 2 つのクローズ ポイントを検索する方法ではないことはわかっていますが、最初にこの方法を試してみたいと思います。

4

1 に答える 1