All problems
SIM(3) Alignment Scale
Problem
Compute the optimal scale of a SIM(3) alignment.
The least-squares scale that maps dst onto src without rotation is sum(dot(src_i, dst_i)) / sum(||dst_i||^2) over the 3D correspondences. Return it rounded to 4 decimal places, or 0.0 when the denominator is 0.
Hint
This is the scalar projection of src onto dst, which minimizes ||src - s * dst||^2.
Test cases
case 1
in: [[[1,0,0],[0,2,0]],[[1,0,0],[0,2,0]]]
expected: 1
case 2
in: [[[2,0,0]],[[1,0,0]]]
expected: 2
case 3
in: [[[0,0,0],[0,0,0]],[[1,1,1],[2,2,2]]]
expected: 0
case 4
in: [[[1,1,0]],[[2,0,0]]]
expected: 0.5
Starter codePython
def sim3_scale(src, dst):
# Your code here
pass4 test cases · run your code against them in the editor