All problems
Apply Inverse Affine Transform
Problem
Given a 2D affine transform defined by matrix A (2x2) and translation t, apply its inverse to point p:
p' = inv(A) * (p - t)
Return None if det(A) == 0.
Hint
Translate first, then undo the linear part with the 2x2 inverse.
Test cases
case 1
in: [[[1,0],[0,1]],[1,1],[3,4]]
expected: [2,3]
case 2
in: [[[2,0],[0,3]],[0,0],[4,9]]
expected: [2,3]
case 3
in: [[[1,1],[0,1]],[1,2],[2,3]]
expected: [0,1]
case 4
in: [[[1,1],[2,2]],[0,0],[1,1]]
expected: null
Starter codePython
def apply_affine_inverse(A, t, p):
# Your code here
pass4 test cases · run your code against them in the editor