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.
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 squareStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started