All problems
ICP Nearest Neighbor Step
Problem
Run one nearest-neighbor step of iterative closest point.
For each source point return the index of the closest target point in 3D Euclidean distance, breaking ties toward the smallest index. Return one index per source point.
Hint
Squared distance gives the same ordering as distance, so skip the square root.
Test cases
case 1
in: [[[0,0,0],[5,5,5]],[[1,0,0],[0,1,0],[4,4,4]]]
expected: [0,2]
case 2
in: [[[1,1,1]],[[0,0,0],[2,2,2]]]
expected: [0]
case 3
in: [[[3,0,0],[0,3,0]],[[3,0,0],[0,3,0],[3,3,3]]]
expected: [0,1]
case 4
in: [[[0,0,0],[10,10,10]],[[-1,-1,-1]]]
expected: [0,0]
Starter codePython
def icp_nearest(source, target):
# Your code here
pass4 test cases · run your code against them in the editor