2D Translation Matrix
Implement a 3×3 homogeneous transformation matrix for 2D translation, which is a fundamental concept in 2D/3D Transformations used to change the position of an object in a 2D space. This transformation is essential in Computer Vision for tasks such as image registration and object tracking.
The concept of homogeneous coordinates allows for efficient representation of geometric transformations, including translation, rotation, and scaling. In the context of 2D translation, a point is represented in homogeneous coordinates as , enabling the use of matrix multiplication to apply the transformation.
To create the transformation matrix, follow these steps:
- Initialize a 3×3 identity matrix.
- Update the last column with the translation values and .
This technique is widely used in image processing applications.
Example
translation_matrix(5, 3)
[[1,0,5],[0,1,3],[0,0,1]]
- Inputs:
txandtyare the shift along the -axis and the -axis. The result is a matrix that moves every 2D point by . - Fill in the form: the left block is the identity, so the shape is not stretched or rotated. The third column holds and , and the bottom row stays . That gives the output
[[1,0,5],[0,1,3],[0,0,1]]. - Check it on a point: write as . Row 1 gives , row 2 gives , and row 3 gives . So the point lands at , which is .
- Notice: the shift only works because of the extra coordinate . It multiplies the third column, which is why a matrix alone can't translate. With the matrix is just the identity.
Constraints
- tx and ty are floating-point numbers
- Return a 3×3 matrix