All problems
Compose Homogeneous Transforms
Problem
Compose two 3x3 homogeneous transforms by matrix multiplication: result = T1 * T2.
Since vectors are transformed as T*v, the transform T2 is applied first, then T1.
Hint
Transform composition is ordinary 3x3 matrix multiplication.
Test cases
case 1
in: [[[1,0,2],[0,1,3],[0,0,1]],[[1,0,1],[0,1,1],[0,0,1]]]
expected: [[1,0,3],[0,1,4],[0,0,1]]
case 2
in: [[[2,0,0],[0,3,0],[0,0,1]],[[1,0,1],[0,1,2],[0,0,1]]]
expected: [[2,0,2],[0,3,6],[0,0,1]]
case 3
in: [[[1,0,0],[0,1,0],[0,0,1]],[[1,0,5],[0,1,7],[0,0,1]]]
expected: [[1,0,5],[0,1,7],[0,0,1]]
case 4
in: [[[1,2,3],[4,5,6],[7,8,9]],[[1,0,0],[0,1,0],[0,0,1]]]
expected: [[1,2,3],[4,5,6],[7,8,9]]
Starter codePython
def compose_homogeneous(T1, T2):
# Your code here
pass4 test cases · run your code against them in the editor