1. Banks Osborne, Christain Braden
Dr. Russell Herman
MAT 365
20 October 2016
Affine Transformations Project
Affine transformations map points from one location to another while preserving one-to-
oneness. Some types of affine transformations are rotations, flipping about axes, scalings,
dilations, and translations. In this project, we explored the affects of transformations upon
triangles represented in the matrix form Lx=Ax+b and worked in MATLAB to reproduce given
shapes by applying affine transformations to a triangle.
First, we found that changing the matrix A=(
1 0
0 1
) to A= (
0.25 0
0 1.5
) produced a
dilation of one-half of the the triangle’s original base and a scaling of one-and-a-half of its
original height. Next, changing the matrix to A=(
1 0
0 −1
) simply flipped the triangle over the x-
axis. Our third transformation involved a variety of transformations. Changing the matrix to
A=(
0.25 −0.433
0.433 0.25
) flipped the triangle over the line y=-x and dilated the base’s original height
to a factor of 0.433. Finally, we changed the matrix to A=(
0.25 0.433
−0.433 0.25
) and added the
translation b=(
0.25
−0.5
) to the equation and found the original triangle was dilated as in the
previous case but was also flipped about the line y=x and translated to the right 0.25 units and
down 0.5 units. These applied examples helped us to generalize the transformations.
The general forms for the transformation (
𝑥′
𝑦′
) are varied. Scaling x by k across the x-axis
can be done by the matrix (
𝑘 0
0 1
). Similarly, scaling about the y-axis can be done by the matrix
2. (
1 0
0 𝑘
). Rotating a matrix clockwise by ß degrees may be accomplished by (
𝑐𝑜𝑠ß 𝑠𝑖𝑛ß
−𝑠𝑖𝑛ß 𝑐𝑜𝑠ß
),
and a counter-clockwise rotation is obtained by changing the signs on the sinß functions. Further,
a reflection about the x-axis is gained by (
1 0
0 −1
), whereas a reflection over the y-axis is by
(
−1 0
0 1
). Additionally, a reflection over the line y=mx is through (
0 1
1 0
) and reflection about
the origin is accomplished through (
−1 0
0 −1
).
Knowing these observations, we used MATLAB to figure out the number and type of
transformations needed to rotate a triangle to match given pictures. To match the first picture, we
set A to be of the form A=(
𝑐𝑜𝑠ß −𝑠𝑖𝑛ß
𝑠𝑖𝑛ß 𝑐𝑜𝑠ß
), where 0 ≤ ß ≤ 360°. The exact matrix we used was
A=(
cos(225) −𝑠𝑖𝑛(225)
sin(225) cos(225)
) with x=(
0
0
). The second picture required a rotation in degrees and
a translation of the original triangle. Consequently, we set A=(
cos(270) sin(270)
−sin(270) cos(270)
)and
x=(
√3
2
−0.25
) to allow for a counter-clockwise rotation of 270. The rotations posed an issue for us
initially because we did not realize MATLAB assumes inputs for trigonometric functions as
radians, but once we found the code for degrees the shapes fell into place.
Our third experiment involved translations, scalings, and rotations to match a picture of
several particularly-oriented rectangles. To form the first two vertical bars we used the same
matrix A=(
0.5cos(90) −0.5sin(90)
0.5sin(90) 0.5cos(90)
) but different translations. The left bar needed to be
farther to the left of the y-axis, so we made x=(
−0.65
0
); and the right bar needed to be farther to
the right of the y-axis, so we made x=(
0.35
0
). We used a similar process to make the slanted bars
3. as well. The matrix was A=(
0.5cos(60) −0.5sin(60)
0.5sin(60) 0.5cos(60)
), and the translation for the left-hand
slanted bar was x=(
−0.1
0
) and the right-hand slanted bar was x=(
0.4
0
). In order to change the
original blue triangle to a blue rectangle, we changed the vertices matrix by adding an additional
(x,y) coordinate and ensured the ordering of its code allowed for the formation of a proper
rectangle.
Lastly, we recreated a rudimentary picture of a cat’s face. In order to make the face, we
reflected the original blue triangle across the x-axis by making A =(
1 0
0 −1
) and changed the
triangle’s coloring to 0.75 of RGB. Next, we made the cat’s left ear. This was accomplished by
A=(
0.5 0
0 0.5
), which allowed the ear to remain one-quarter the size of the face. The difference
between the right ear and the left ear is that the right ear was translated by x=(
0.5
0
). The cat’s
nose is slightly smaller than the ear’s, so we defined A=(
0.25 0
0 0.25
); and to make the face
symmetrical, we translated the nose by x=(
0.375
−0.5
). The eyes are a scaling and a reflection. They
were scaled and reflected by A=(
0.25 0
0 −0.25
). Continuing with the theme of making the face
symmetrical, we ensured the inside vertices of the eyes were an equal distance apart from the
middle of the face. The left eye was translated by x=(
0.166
−0.125
) and the right was translated by
x=(
0.584
−0.125
). Forming the pupils followed a similar pattern as making the eyes, but we used
A=(
0.15 0
0 0.15
) instead to adjust the scale. Finally, making the lips included a rotation and a
scaling. The matrix A=(
0.05cos(90) −0.05sin(90)
0.05sin(90) 0.05cos(90)
) represents these transformations. Since
the two sides of the lips were at different heights we needed two translations. The left translation
4. was by x=(
0.5
−0.7
) and the right was by x=(
0.5
−0.65
). After successfully recreating the lips, our
cat’s face mimicked the given picture.
In hindsight, these experiments testing linear transformations proved challenging but
rewarding. Through some initial applied processes, we were able to generate generalized forms
of transformations that allowed us to recreate basic, rudimentary pictures. This written analysis,
however, does not include all of the details of some of the methods used. For example, in the
latter experiments we had to repeat some matrices in order to create new shapes without messing
with existing ones. Describing in detail these types of operations would be lengthy. For
convenience, all code used throughout this project is included in the Appendix.
5. Appendix
Rotation 1
clear
% Specify Vertices -
v=[0 0; 1 0; 0.5 sqrt(3)/2 ];
% Draw Blue Triangle
patch(v(:,1), v(:,2),'b');
% Set Scale of Axes
axis([-1 2 -1 2])
axis square
% Hold Figure to add next triangle
hold on
% Transform Triangle w = Av+b
% Specify Transformations A = [a b; c d]
%A transforms scaling matrix by n, sign changes reflect across axis,
%row1=yaxis row2=xaxis
A=[cosd(225) -sind(225); sind(225) cosd(225)];
% b changes the coordinate position
b=[0 0];
w=A*v';
%repmat copies (var, row, colm)
% w' = transpose ofw
w=w'+repmat(b,3,1);
% Draw Red Triangle using RGB scaling
patch(w(:,1), w(:,2),[1 0 0]);
hold off
Rotation 2
clear
% Specify Vertices -
v=[0 0; 1 0; 0.5 sqrt(3)/2 ];
% Draw Blue Triangle
patch(v(:,1), v(:,2),'b');
% Set Scale of Axes
axis([-1 2 -1 2])
axis square
% Hold Figure to add next triangle
hold on
% Transform Triangle w = Av+b
% Specify Transformations A = [a b; c d]
%A transforms scaling matrix by n, sign changes reflect across axis,
%row1=yaxis row2=xaxis
A=[cosd(270) sind(270); -sind(270) cosd(270)];
% b changes the coordinate position
b=[sqrt(3)/2 -0.25];
w=A*v';
%repmat copies (var, row, colm)
% w' = transpose ofw
w=w'+repmat(b,3,1);
% Draw Red Triangle using RGB scaling
patch(w(:,1), w(:,2),[1 0 0]);
hold off
6. Rotation, Translation, and Scaling of Bars
clear
% Specify Vertices -
v=[-1 -.25; 1 -.25; 1 .25; -1 .25 ];
%f=[1 2 3 4]
%patch('Faces',f,'Vertices',v,'FaceColor','b')
% Draw Blue Triangle
patch(v(:,1), v(:,2),'b');
% Set Scale of Axes
axis([-1 1 -1 1])
axis square
%vertical bar 1 & 2
hold on
A=[.5*cosd(90) -.5*sind(90) ; .5*sind(90) .5*cosd(90)];
b=[0.65 0];
w=A*v';
w=w'+repmat(b,4,1);
patch(w(:,1), w(:,2),[1 0 0]);
hold off
hold on
A=[.5*cosd(90) -.5*sind(90) ; .5*sind(90) .5*cosd(90)];
b=[-0.35 0];
w=A*v';
w=w'+repmat(b,4,1);
patch(w(:,1), w(:,2),[1 0 0]);
hold off
% slanted bar 1
hold on
A=[.5*cosd(60) -.5*sind(60) ; .5*sind(60) .5*cosd(60)];
b=[.4 0];
w=A*v';
w=w'+repmat(b,4,1);
patch(w(:,1), w(:,2),[1 0 0]);
hold off
%slanted bar 2
hold on
A=[.5*cosd(-60) -.5*sind(-60) ; .5*sind(-60) .5*cosd(-60)];
b=[-0.1 0];
w=A*v';
w=w'+repmat(b,4,1);
patch(w(:,1), w(:,2),[1 0 0]);
hold off
7. Creation of Cat Face
clear
% Specify Vertices -
v=[0 0; 1 0; 1/2 sqrt(3)/2];
% Draw Blue Triangle
hold off
patch(v(:,1), v(:,2), 'b');
hold off
% Set Scale of Axes
axis([0 1 -1 1])
axis square
% Hold Figure to add next triangle
%face triangle
% Transform Triangle w = Av+b
% Specify Transformations A = [a b; c d]
%A transforms scaling matrix by n, sign changes reflect across axis,
%row1=yaxis row2=xaxis
A=[1 0; 0 -1];
% b changes the coordinate position
b=[0 0];
w=A*v';
%repmat copies (var, row, colm)
% w' = transpose ofw
w=w'+repmat(b,3,1);
% Draw Red Triangle using RGB scaling
patch(w(:,1), w(:,2),[0.75 0.75 0.75]);
%ears
A=[.5 0; 0 .5];
b=[0 0];
w=A*v';
w=w'+repmat(b,3,1);
patch(w(:,1), w(:,2),[0.75 0.75 0.75]);
A=[.5 0; 0 .5];
b=[.5 0];
w=A*v';
w=w'+repmat(b,3,1);
patch(w(:,1), w(:,2),[0.75 0.75 0.75]);
%nose
A=[.25 0; 0 .25];
b=[0.375 -.5];
w=A*v';
w=w'+repmat(b,3,1);
patch(w(:,1), w(:,2),[.5 .3 0]);
% eyes
A=[.25 0; 0 -.25];
b=[.166 -.125];
w=A*v';
w=w'+repmat(b,3,1);
patch(w(:,1), w(:,2),[1 1 1]);
A=[.25 0; 0 -.25];
b=[.584 -.125];
w=A*v';
w=w'+repmat(b,3,1);
patch(w(:,1), w(:,2),[1 1 1]);
%pupils