Starting from:

$29

Math 232 – Computing Assignment 2 SOLVED

Math 232 – Computing Assignment 2
Programming Preamble:
This bit of Matlab code draws a rectangle. It also places 3 coloured stars at 3 of the corners.
x1=0; x2=1;
y1=0;
y2=2;
x = [x1, x2, x2, x1, x1];
y = [y1, y1, y2, y2, y1];
plot(x, y, ’k-’, ’LineWidth’, 1);
hold on;
>> P=[0 1 1 0;0 0 2 2];
>> plot(P(1,1),P(2,1),’r*’);
>> plot(P(1,2),P(2,2),’g*’);
>> plot(P(1,4),P(2,4),’b*’);
>> axis([-1 3 -1 3]);
1
Computing Assignment
Required submission: 1 page PDF document with your answers to the problems here, and a PDF
document with your Matlab or Python code (exported to a .pdf file), both uploaded to Crowdmark
(so, upload 2 things - a one page report and the PDF of your code.).
This computing assignment is designed so that you will demonstrate to yourself that matrices
operate on vectors in R
2
in a way that we can observe geometrically.
1. Part 1 - Geometric transformations
• Vectors
First, choose 2 vectors (note that in the code above these two vectors are (0, 0) and
(1, 2)) the terminal points of which are used to form a rectangle. Plot this rectangle
using code similar to that provided above. Then choose TWO different matrices each
of which performs a single geometric operation of your choice. In both cases, multiply
your 2 vectors by these matrices and plot the resulting rectangles. Include one plot in
your report which shows your original rectangle and your two transformed rectangles.
Include the matrices you used to do the transformation.
• Composition
Verify the result of Problem A6 in Section 3.3 of the text; that the two compositions of a
vertical shear and a stretch in the y direction, do not commute. Do this by plotting the
image of the unit square with corners at (1, 1),(2, 1),(2, 2),(1, 2). Then plot the results
of applying the COMPOSITION of the two operations (vertical shear and stretch) in
both orders and showing that the resulting shape depends on the order in which the
operations are applied. Corroborate your ’experimental proof’ of the non-commutability
of these transformations by referring to Theorem 3.2.5 of the text (i.e., by considering
the associated matrices).
Part 2 −→
2
2. Part 2 - Manipulating an Image
• Consider the following picture:
• Find the matrix that transforms the black rectangle into the red rectangle. Look at
the diagram and observe what has happened to the black rectangle. Form the matrices
that do these operations; there are two. Multiply these matrices in the correct order
to get the transformation matrix A. Experimentally verify that you can plot the black
rectangle yourself and then multiply the vectors that describe the opposite vertices by
A and obtain and plot the red rectangle. Include the matrices you used to do this in
your report.
3

More products