Skip to content
DeepForgeby svx
All problems
MediumLinear Algebrala-170

Inverse Homogeneous Transform

Problem

Invert a 3x3 homogeneous transform T = [[A, t], [0, 0, 1]], where A is an invertible 2x2 linear part and t is a translation.

Return [[inv(A), -inv(A)*t], [0, 0, 1]], or None if det(A) == 0.

Hint

For a rotation plus translation, the inverse rotation is the transpose; here use the general 2x2 inverse.

Test cases

case 1
in: [[[1,0,2],[0,1,3],[0,0,1]]]
expected: [[1,0,-2],[0,1,-3],[0,0,1]]
case 2
in: [[[2,0,0],[0,3,0],[0,0,1]]]
expected: [[0.5,0,0],[0,0.3333333333333333,0],[0,0,1]]
case 3
in: [[[1,0,0],[0,1,0],[0,0,1]]]
expected: [[1,0,0],[0,1,0],[0,0,1]]
case 4
in: [[[0,-1,0],[1,0,1],[0,0,1]]]
expected: [[0,1,-1],[-1,0,0],[0,0,1]]
Starter codePython
def inverse_homogeneous(T):
    # Your code here
    pass

4 test cases · run your code against them in the editor