Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

***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.

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advanced Database Systems

Authors: Carlo Zaniolo, Stefano Ceri, Christos Faloutsos, Richard T. Snodgrass, V.S. Subrahmanian, Roberto Zicari

1st Edition

155860443X, 978-1558604438

More Books

Students also viewed these Databases questions

Question

=+j Improve the effectiveness of global and virtual teams.

Answered: 1 week ago