- You trying to translate a 2D plane shape to different points using a transformation matrix which is of size 3x3.
- The transformation matrix you have is a 3x3matrix, which is the correct size for affine transformation when using homogeneous coordinates.
- The plane matrix is also correctly structured to be multiplied by the transformation matrix T.
However, there are a few issues with your code:
- You are multiplying the ‘plane’ matrix by the transformation matrix ‘T’ in the wrong order. The correct order is to multiply ‘T’ by ‘plane’ from the left, no the right.
- You are using ‘plot_polygon(planeNEW)’ without showing the implementation of the function. I am assuming this function plots the polygon defined by the input matrix.
- For the translation to look like an animation, you should clear the figure before the next iteration.
You can refer to the code for the loop given below:
% Animate the plane translation
for i = 1:length(x)
T = [1, 0, x(i); 0, 1, y(i); 0, 0, 1]; % Transformation matrix
planeNEW = T * plane; % Apply the transformation
plot_polygon(planeNEW); % Plot the transformed plane
pause(0.5);
if i < length(x)
clf; % Clear the figure for the next iteration
end
end