📘
2D Translation Matrix
EasyGeometry
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 (x,y) is represented in homogeneous coordinates as (x,y,1), 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 tx and ty.
This technique is widely used in image processing applications.
Example:
Input:
translation_matrix(5, 3)
Output:
[[1,0,5],[0,1,3],[0,0,1]]
Reasoning:
- The function
translation_matrix(5, 3)means we want a 2D translation by tx=5 units in x and ty=3 units in y. - The homogeneous 2D translation matrix has the fixed form T=100010txty1
- Substituting tx=5 and ty=3 gives T=100010531
- Converting this matrix to list form yields the output
[[1,0,5],[0,1,3],[0,0,1]].
Constraints:
- tx and ty are floating-point numbers
- Return a 3×3 matrix
Editor
Python 3.13.1
Test Results
0/0Run code to see test results.