Question: Example 9 In this example we first translate the square horizontally 1 2 units using increments of 0 . 4 . We then rotate the
Example
In this example we first translate the square horizontally units using increments of We then
rotate the resulting square clockwise pi radians around the vertex using increments of pi
radians.
clf
S;;; square in homogeneous coordinates
M;;; first translation matrix
theta pi; define the angle theta
Q costhetasintheta;sintheta costheta;; rotation matrix about
QP ;;Q;;; rotation matrix about
p plotS:S:; plot the original square
axis equal, axis grid on
for i :
S MS; compute the translated square
setp'xdata',S:'ydata',S:; plot the translated square
pause
end
for i :
SQPS; compute the rotated square
setp'xdata',S:'ydata',S:; plot the rotated square
pause
end
EXERCISES
Consider the square in EXAMPLE The goal of this exercise is to bring back the square to its
original position by first translating it horizontally to the left units using iterations, and
then rotating it counterclockwise pi radians around the point using iterations. This
can be done by modifying the code in EXAMPLE by adding two for loops. The first loop
should translate the square while the second should rotate it around the point Note that
the rotation is counterclockwise, while in EXAMPLE it was clockwise. Include the Mfile.
You do not need to include the figure.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
