Homework Assignment 1

This assignment has two parts. 1. Create initials through plots. 2. Show linear transformations through animations on the initials.

Part 1

I honestly had a hard time trying to plot out my initials. My last name is Baker. I know that the “B” would require some trig functions. However, I have no experience doing this at all so I decided to try to make my life easier by using the first two letters of my first name “Ty”.

T

I decided to start by trying to plot letter by letter first to gather an understanding.

y = c(rep(1,1000),seq(-1,1,length.out=500), rep(1,1000))
x = c(seq(1,-1,length.out=1000),rep(0,500),seq(-1,1,length.out=1000))
z = rbind(x,y)
plot(y~x, xlim=c(-3,3), ylim=c(-3,3))

Y

u = c(seq(0,2,length.out=500),seq(-2,2,length.out=500))
v = c(seq(0,-1,length.out=500),seq(-2,2,length.out=500))
w = rbind(u,v)
plot(u~v, xlim=c(-3,3), ylim=c(-3,3))

Combing the letters together

Here, I ran into an issue. Both of my letters are being plotted correctly, however they are overlapping each other. I can’t figure out what I did incorrectly. For the sake of complete the assignment and moving forward I decided that I will work with the overlapping letters.

y = c(rep(1,1000),seq(-1,1,length.out=500), rep(1,1000), seq(0,1,length.out=500), seq(-1,1, length.out=500))
plot(y)

x = c(seq(1,-1,length.out=1000),rep(0,500),seq(-1,1,length.out=1000),seq(0,-1,length.out=500), seq(-1,1,length.out=500))
plot(x)

initials = rbind(x,y)
plot(y~x, xlim=c(-3,3), ylim=c(-3,3))

Part 2

Shear

A shear is essentially a tilt. A shear can be done verically or horizontally. I chose to use a vertical shear.

for (i in 0:5 ){
  shear_c_one <- c(1,0)
  shear_c_two <- c(i,1)
  shear_matrix <- cbind(shear_c_one,shear_c_two)
  z<-shear_matrix %*% initials
  plot_shear<- plot(z[2,]~z[1,] , xlim=c(-3,3), ylim=c(-3,3))
}

Scaling

Scaling is growing or shrinking an image. I decided to show a growing image.

for (i in 1:5) {
  scale_c_one <- c(i,0)
  scale_c_two <- c(0,i)
  scale_mat <- cbind(scale_c_one, scale_c_two)
  z<- scale_mat %*% initials
  plot_scale<- plot(z[2,]~z[1,], xlim=c(-3,3),ylim=c(-3,3))
}

Rotation

Rotation is just as it sounds. An image can be rotated around any axis or plane. I decided to rotate around the y-axis.

for (i in c(1,-1,1,-1,1,-1,1)) {
  rotate_c_one <- c(i,0)
  rotate_c_two <- c(0,1)
  rotate_mat <- cbind(rotate_c_one, rotate_c_two)
  z<- rotate_mat %*% initials
  plot_rotate <- plot(z[2,]~z[1,], xlim=c(-3,3), ylim=c(-3,3))
}

Projection

A projection is basically collapsing a dimension of an image. In this example the image is being collapsed into a horizontal line.

for (i in c(1,0,1,0,1,0)) {
  projection_c_one <- c(1,0)
  projection_c_two <- c(0,i)
  projection_mat <- cbind(projection_c_one, projection_c_two)
  z<- projection_mat %*% initials
  plot_projection <- plot(z[2,]~z[1,], xlim=c(-3,3), ylim=c(-3,3))
}