Question: ***THIS MUST BE DONE IN MATLAB*** 7. Consider the square in EXAMPLE 9. The goal of this exercise is to bring back the square to

***THIS MUST BE DONE IN MATLAB***

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 two units using 20 iterations, and then rotating it counterclockwise /2 radians around the point (1, 0) using 5 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.

***THIS MUST BE DONE IN MATLAB*** 7. Consider the square in EXAMPLE

EXAMPLE In this example we first translate the square horizontally 2 units using increments of 0.1. We then rotate the resulting square clockwise /2 radians around the vertex (3.0) using increments of /10 radians clf s-[0 , , ,0 , 0; 0 ,0 , 1 , 1 , 0; 1 , 1 , 1 , 1 , 1] ; % define the square in homogeneous coordinates M1- [1,0,0. 1:0, 1,0;0,0,1]; % define the first translation matrix theta pi/10: % define the angle theta q-[cos(theta),-sin(thet a) ,0; sin(thet a),cos(theta),0;0,0,1]; % rotation matrix about the origin QP-[1,0 , 3:0, 1, 0:0 ,0, 1]Q,* [1,0,-3:0, ,0;0,0,1] ; % define the rotation matrix around (3,0) p- plot(S (1, :),S(2, :)); % plot the original tsquare axis([-0.5,5,-0.5,2]), grid on axis egual figure(gcf) for i1:20 S M1*S; % compute the translated square set (p, Xdat a ,,S(1, :),,ydata,, S (2, :)); % plot the translated square pause(0.2) SAP#8; % compute the rotated square set(p, Xdata,,S(1, ,,ydata,,S(2, :)) ; pause(0.2) % plot the rotated square

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!