Plotting and computer animation in MATLAB
Instructions: For each of the following exercise, create an M-file to store the MATLAB commands. Copy and paste the M-file into a text document. For problems 1 and 2, include in the text document the pictures produced by MATLAB. Resize and crop the pictures so that they do not take up too much space. If the question requires written answers, include them in the text file in the appropriate location. Make sure you clearly label and separate all the Exercises. For problems 3 and 4 you do not need to include the picture.
1. Consider the original triangle T.Reflect the triangle about the line at 45o and plot the reflection together with the original triangle. Add a grid, a legend and title.
2. Consider the original triangle T. First rotate the triangle 45o counterclockwise and then reflect the triangle about the line at 45o. Plot the resulting triangle and compare with the plot in Example
4. Are the results the same? Does the order of the transformations matter?
3. Adapt the procedure developed in Example 5 to rotate the triangle couunterclockwise by increments of Π/20 about the origin. Stop when the triangle is in its original location and then rotate it in the clockwise direction until the triangle is in its original location again. If the pause command is set properly, it should appear that the triangle is moving around a circle. You may want to rescale the axis.
4. Adapt the procedure developed in Example 5 to show the triangle rotating in a counterclockwise direction about the origin by increments of Π/20 (for a total angle of Π/2) and expanding at the same time by a factor of 1.25, then stopping and rotating in the clockwise direction as it shrinks to its original size (with a contraction factor of .8). At the end of the program, the figure should have returned to its original size and original location.
5. (a) Modify the M-file in EXAMPLE 6 adding translations that bring the triangle to its original position using 20 iterations.
(b) Write down a rotation matrix Q that rotates a vector in homogeneous coordinates Π/40 radians in the counterclockwise direction. Then modify the M-file in part (a) adding to each iteration (for all three loops) a rotation defined by the matrix Q.
Note that the triangle should NOT end up in its original location like it should for 5(a). You might need to change the axes to see where it "lands."
Attachment:- Plotting and computer animation in MATLAB.pdf