Skip to content
DeepForgeby svx
All problems
MediumLinear Algebrala-037

Homogeneous Translation Matrix

Problem

Build the 3x3 homogeneous translation matrix that shifts a 2D point by (tx, ty):

T = [[1, 0, tx], [0, 1, ty], [0, 0, 1]]

Hint

The translation lives in the last column of the homogeneous matrix.

Test cases

case 1
in: [2,3]
expected: [[1,0,2],[0,1,3],[0,0,1]]
case 2
in: [0,0]
expected: [[1,0,0],[0,1,0],[0,0,1]]
case 3
in: [-1,4]
expected: [[1,0,-1],[0,1,4],[0,0,1]]
case 4
in: [1.5,-2.5]
expected: [[1,0,1.5],[0,1,-2.5],[0,0,1]]
Starter codePython
def translation_matrix(tx, ty):
    # Your code here
    pass

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