Question: Please i need help with MATLAB code. Thank you 7. Consider the square in EXAMPLE 9. The goal of this exercise is to bring back


Please i need help with MATLAB code. Thank you
7. Consider the square in EXAMPLE 9. The goal of this exercise is to bring back the square to its original position by first translating it horizontally to the left 6 units using 30 iterations, and then rotating it counterclockwise /2 radians around the point (1,0) using 4 iterations. This can be done by modifying the code in EXAMPLE 9 by adding two for loops. The first loop should translate the square while the second should rotate it around the point (1,0). Note that the rotation is counterclockwise, while in EXAMPLE 9 it was clockwise. Include the M-file. You do not need to include the figure. EXAMPLE 9 In this example we first translate the square horizontally 6 units using increments of 0.2. We then rotate the resulting square clockwise /2 radians around the vertex (7,0) using increments of /8 radians clf s-[0, 1 , 1 ,0 ,0:0 ,0 , 1 , 1 ,0:1 , 1 , 1 ,1 , 1); % square in homogeneous coordinates M1 [1 ,0 ,0 . 2;0,1,0;0,0,1); % first translation matrix theta pi /8 ; % define the angle theta Q=[cos (theta),-sin ( t heta) ,0; sin(theta),cos (the ta),0,0,0,1); % rotation matrix about QP=[1 ,0 ,7 ; 0 , 1,0:0,0,1]*0' * [1,0,-7;0,1,0:0,0,11; % rotation natrix about (7,0) P plot (S(1,:) ,s(2, :)); % plot the original square axis equal, axis (-0.5,9,-2,5]), grid on figure(gcf) for i 1:30 (0,0) S M1*S; % compute the translated square set (p,'zdata',S(1, :),'ydata',s(2, :)); % plot pause (0.1) the translated square end for i 1:4 s-QPeS; % compute the rotated square set (p,'xdata. , s (1, :),'ydata',s(2, :)); % plot the rotated square pause (0.1) end
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
