SlideShare a Scribd company logo
1 of 8
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
(
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
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
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.
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
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
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
A=[.15 0; 0 -.15];
b=[.215 -.2116];
w=A*v';
w=w'+repmat(b,3,1);
patch(w(:,1), w(:,2),[0 1 0]);
A=[.15 0; 0 -.15];
b=[.635 -.2116];
w=A*v';
w=w'+repmat(b,3,1);
patch(w(:,1), w(:,2),[0 1 0]);
%mouth
A=[.05*cosd(90) -.1*sind(90); .05*sind(90) -.1*cosd(90)];
b=[0.5 -.7];
w=A*v';
w=w'+repmat(b,3,1);
patch(w(:,1), w(:,2),[.8 0 .1]);
A=[.05*cosd(-90) -.1*sind(-90); .05*sind(-90) -.1*cosd(-90)];
b=[0.5 -.65];
w=A*v';
w=w'+repmat(b,3,1);
patch(w(:,1), w(:,2),[.8 0 .1]);

More Related Content

What's hot

Geometric transformation 2d chapter 5
Geometric transformation 2d   chapter 5Geometric transformation 2d   chapter 5
Geometric transformation 2d chapter 5geethawilliam
 
Reflection, Scaling, Shear, Translation, and Rotation
Reflection, Scaling, Shear, Translation, and RotationReflection, Scaling, Shear, Translation, and Rotation
Reflection, Scaling, Shear, Translation, and RotationSaumya Tiwari
 
2d-transformation
2d-transformation2d-transformation
2d-transformationPooja Dixit
 
Geometry unit 9.3
Geometry unit 9.3Geometry unit 9.3
Geometry unit 9.3Mark Ryder
 
Function transformations
Function transformationsFunction transformations
Function transformationsTerry Gastauer
 
2 d transformations and homogeneous coordinates
2 d transformations and homogeneous coordinates2 d transformations and homogeneous coordinates
2 d transformations and homogeneous coordinatesTarun Gehlot
 
2D Transformation
2D Transformation2D Transformation
2D TransformationShahDhruv21
 
2001 transformations reflections etc
2001 transformations reflections etc2001 transformations reflections etc
2001 transformations reflections etcjbianco9910
 
2 d transformations by amit kumar (maimt)
2 d transformations by amit kumar (maimt)2 d transformations by amit kumar (maimt)
2 d transformations by amit kumar (maimt)Amit Kapoor
 
Geometric objects and transformations
Geometric objects and transformationsGeometric objects and transformations
Geometric objects and transformationssaad siddiqui
 
3d transformation computer graphics
3d transformation computer graphics 3d transformation computer graphics
3d transformation computer graphics University of Potsdam
 
04transformation2d
04transformation2d04transformation2d
04transformation2dKetan Jani
 
2D Transformations(Computer Graphics)
2D Transformations(Computer Graphics)2D Transformations(Computer Graphics)
2D Transformations(Computer Graphics)AditiPatni3
 
2D transformation (Computer Graphics)
2D transformation (Computer Graphics)2D transformation (Computer Graphics)
2D transformation (Computer Graphics)Timbal Mayank
 
Geometry unit 9.1
Geometry unit 9.1Geometry unit 9.1
Geometry unit 9.1Mark Ryder
 
Supot37255412160
Supot37255412160Supot37255412160
Supot37255412160Ajay Ochani
 
Horizontal Shifts of Quadratic Functions
Horizontal Shifts of Quadratic Functions Horizontal Shifts of Quadratic Functions
Horizontal Shifts of Quadratic Functions MarkBredin
 
Matrix 2 d
Matrix 2 dMatrix 2 d
Matrix 2 dxyz120
 

What's hot (20)

Geometric transformation 2d chapter 5
Geometric transformation 2d   chapter 5Geometric transformation 2d   chapter 5
Geometric transformation 2d chapter 5
 
Reflection, Scaling, Shear, Translation, and Rotation
Reflection, Scaling, Shear, Translation, and RotationReflection, Scaling, Shear, Translation, and Rotation
Reflection, Scaling, Shear, Translation, and Rotation
 
2d-transformation
2d-transformation2d-transformation
2d-transformation
 
Transformations
TransformationsTransformations
Transformations
 
Geometry unit 9.3
Geometry unit 9.3Geometry unit 9.3
Geometry unit 9.3
 
Function transformations
Function transformationsFunction transformations
Function transformations
 
2 d transformations and homogeneous coordinates
2 d transformations and homogeneous coordinates2 d transformations and homogeneous coordinates
2 d transformations and homogeneous coordinates
 
2D Transformation
2D Transformation2D Transformation
2D Transformation
 
2001 transformations reflections etc
2001 transformations reflections etc2001 transformations reflections etc
2001 transformations reflections etc
 
2 d transformations by amit kumar (maimt)
2 d transformations by amit kumar (maimt)2 d transformations by amit kumar (maimt)
2 d transformations by amit kumar (maimt)
 
Geometric objects and transformations
Geometric objects and transformationsGeometric objects and transformations
Geometric objects and transformations
 
3d transformation computer graphics
3d transformation computer graphics 3d transformation computer graphics
3d transformation computer graphics
 
04transformation2d
04transformation2d04transformation2d
04transformation2d
 
2D Transformations(Computer Graphics)
2D Transformations(Computer Graphics)2D Transformations(Computer Graphics)
2D Transformations(Computer Graphics)
 
Transforms UNIt 2
Transforms UNIt 2 Transforms UNIt 2
Transforms UNIt 2
 
2D transformation (Computer Graphics)
2D transformation (Computer Graphics)2D transformation (Computer Graphics)
2D transformation (Computer Graphics)
 
Geometry unit 9.1
Geometry unit 9.1Geometry unit 9.1
Geometry unit 9.1
 
Supot37255412160
Supot37255412160Supot37255412160
Supot37255412160
 
Horizontal Shifts of Quadratic Functions
Horizontal Shifts of Quadratic Functions Horizontal Shifts of Quadratic Functions
Horizontal Shifts of Quadratic Functions
 
Matrix 2 d
Matrix 2 dMatrix 2 d
Matrix 2 d
 

Similar to Affine Transformations Project Recreates Shapes

2 d transformation
2 d transformation2 d transformation
2 d transformationAnkit Garg
 
Transformations lower secondary fil..ppt
Transformations lower secondary fil..pptTransformations lower secondary fil..ppt
Transformations lower secondary fil..pptMUHAMMADARSALANASIFA
 
Linear Algebra Gauss Jordan elimination.pptx
Linear Algebra Gauss Jordan elimination.pptxLinear Algebra Gauss Jordan elimination.pptx
Linear Algebra Gauss Jordan elimination.pptxMaths Assignment Help
 
Obj. 30 Reflections and Translations
Obj. 30 Reflections and TranslationsObj. 30 Reflections and Translations
Obj. 30 Reflections and Translationssmiller5
 
Lecture 07 graphing linear equations
Lecture 07 graphing linear equationsLecture 07 graphing linear equations
Lecture 07 graphing linear equationsHazel Joy Chong
 
ALA Solution.pdf
ALA Solution.pdfALA Solution.pdf
ALA Solution.pdfRkAA4
 
Booklet shilov plotting-graphs
Booklet shilov plotting-graphsBooklet shilov plotting-graphs
Booklet shilov plotting-graphsarantheo
 
Batman logo and word student sample
Batman logo and word student sampleBatman logo and word student sample
Batman logo and word student sampleAngela Phillips
 
Transformations zambia
Transformations zambiaTransformations zambia
Transformations zambiaRasford Munga
 
2.1. fundamental of computer graphics
2.1. fundamental of computer graphics2.1. fundamental of computer graphics
2.1. fundamental of computer graphicsRatnadeepsinh Jadeja
 
Computer Graphic - Transformations in 2D
Computer Graphic - Transformations in 2DComputer Graphic - Transformations in 2D
Computer Graphic - Transformations in 2D2013901097
 
Computer Graphics & linear Algebra
Computer Graphics & linear Algebra Computer Graphics & linear Algebra
Computer Graphics & linear Algebra Xad Kuain
 

Similar to Affine Transformations Project Recreates Shapes (20)

2 d transformation
2 d transformation2 d transformation
2 d transformation
 
Transformations lower secondary fil..ppt
Transformations lower secondary fil..pptTransformations lower secondary fil..ppt
Transformations lower secondary fil..ppt
 
Linear Algebra Gauss Jordan elimination.pptx
Linear Algebra Gauss Jordan elimination.pptxLinear Algebra Gauss Jordan elimination.pptx
Linear Algebra Gauss Jordan elimination.pptx
 
Obj. 30 Reflections and Translations
Obj. 30 Reflections and TranslationsObj. 30 Reflections and Translations
Obj. 30 Reflections and Translations
 
Lecture 07 graphing linear equations
Lecture 07 graphing linear equationsLecture 07 graphing linear equations
Lecture 07 graphing linear equations
 
ALA Solution.pdf
ALA Solution.pdfALA Solution.pdf
ALA Solution.pdf
 
SinogramReconstruction
SinogramReconstructionSinogramReconstruction
SinogramReconstruction
 
Booklet shilov plotting-graphs
Booklet shilov plotting-graphsBooklet shilov plotting-graphs
Booklet shilov plotting-graphs
 
Batman logo and word student sample
Batman logo and word student sampleBatman logo and word student sample
Batman logo and word student sample
 
Mat 223_Ch5-Eigenvalues.ppt
Mat 223_Ch5-Eigenvalues.pptMat 223_Ch5-Eigenvalues.ppt
Mat 223_Ch5-Eigenvalues.ppt
 
Transformations zambia
Transformations zambiaTransformations zambia
Transformations zambia
 
Transformations
TransformationsTransformations
Transformations
 
2.1. fundamental of computer graphics
2.1. fundamental of computer graphics2.1. fundamental of computer graphics
2.1. fundamental of computer graphics
 
Digtial Image Processing Q@A
Digtial Image Processing Q@ADigtial Image Processing Q@A
Digtial Image Processing Q@A
 
Transf handout
Transf handoutTransf handout
Transf handout
 
3 D Graphics
3 D Graphics3 D Graphics
3 D Graphics
 
Computer Graphic - Transformations in 2D
Computer Graphic - Transformations in 2DComputer Graphic - Transformations in 2D
Computer Graphic - Transformations in 2D
 
Computer Graphics - transformations in 2d
Computer Graphics - transformations in 2dComputer Graphics - transformations in 2d
Computer Graphics - transformations in 2d
 
Computer Graphics & linear Algebra
Computer Graphics & linear Algebra Computer Graphics & linear Algebra
Computer Graphics & linear Algebra
 
3.-Matrix.pdf
3.-Matrix.pdf3.-Matrix.pdf
3.-Matrix.pdf
 

Affine Transformations Project Recreates Shapes

  • 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
  • 8. A=[.15 0; 0 -.15]; b=[.215 -.2116]; w=A*v'; w=w'+repmat(b,3,1); patch(w(:,1), w(:,2),[0 1 0]); A=[.15 0; 0 -.15]; b=[.635 -.2116]; w=A*v'; w=w'+repmat(b,3,1); patch(w(:,1), w(:,2),[0 1 0]); %mouth A=[.05*cosd(90) -.1*sind(90); .05*sind(90) -.1*cosd(90)]; b=[0.5 -.7]; w=A*v'; w=w'+repmat(b,3,1); patch(w(:,1), w(:,2),[.8 0 .1]); A=[.05*cosd(-90) -.1*sind(-90); .05*sind(-90) -.1*cosd(-90)]; b=[0.5 -.65]; w=A*v'; w=w'+repmat(b,3,1); patch(w(:,1), w(:,2),[.8 0 .1]);