library(gifski)

Build the first letters for both your first and last name using point plots in R

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

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

z <- rbind(x,y)

plot(y~x, xlim=c(-3,3), ylim=c(-3,3), col = "turquoise",
     main = "My Initials")

Write R code that will left multiply (%*%) a square matrix (x) against each of the vectors of points (y). Initially, that square matrix will be the Identity matrix.

Use a loop that changes the transformation matrix incrementally to demonstrate

  1. shear
  2. scaling
  3. rotation
  4. projection in animated fashion.

Shear

x11()

for (val in seq(-2,2,length.out=50)) {
  shear_matrix <- matrix(c(2, 0, val, 1), nrow=2, ncol=2)
  shear <- apply(z, 2, function(x) x %*% shear_matrix) 
  plot(shear[2,] ~ shear[1,], xlim=c(-8, 8), ylim=c(-8, 8), col = "turquoise", 
       main = "Shear")
  Sys.sleep(0.05)
}

Scale

x11()

for (val in seq(1,3,length.out=50)) {
  scale_matrix <- matrix(c(val, 0, 0, val), nrow=2, ncol=2)
  scale <- apply(z, 2, function(x) x %*% scale_matrix)
  plot(scale[2,] ~ scale[1,], xlim=c(-8,8), ylim=c(-8,8), col = "turquoise", 
       main = "Scale")
  Sys.sleep(0.05)
  }

Rotation

x11()

for (val in seq(-3,3,length.out=50)) {
  rotation_matrix <- matrix(c(cos(val), -sin(val), sin(val), cos(val)), nrow=2, ncol=2)
  rotate <- apply(z, 2, function(x) x %*% rotation_matrix)
  plot(rotate[2,] ~ rotate[1,], xlim=c(-8,8), ylim=c(-8,8), col = "turquoise",
       main = "Rotate")
  Sys.sleep(0.05)
  }

Projection

x11()

for (val in seq(-3,3,length.out=50)) {
  projection_matrix <- matrix(c(val,0,0,1), nrow=2, ncol=2)
  projection <- apply(z, 2, function(x) x %*% projection_matrix)
  plot(projection[2,] ~ projection[1,], xlim=c(-8,8), ylim=c(-8,8), col = "turquoise", main = "Projection")
  Sys.sleep(0.05)
}