Load library

suppressMessages({
  library(tidyverse)
})

Part 1: Plot initials FA

x_f = c(rep(0, 500), 
        seq(0, 1, length.out = 500),
        seq(0, 1, length.out = 500))

y_f = c(seq(-1, 1, length.out = 500),
        rep(1, 500),
        rep(0, 500))

z_f = rbind(x_f, y_f)

plot(y_f ~ x_f, xlim = c(-3, 3), ylim = c(-3, 3))

x_a = c(rep(1.5, 500), 
        seq(1.5, 2.5, length.out = 500),
        seq(1.5, 2.5, length.out = 500),
        rep(2.5, 500))

y_a = c(seq(-1, 1, length.out = 500),
        rep(1, 500),
        rep(0, 500),
        seq(-1, 1, length.out = 500))

z_a = rbind(x_a, y_a)

plot(y_a ~ x_a, xlim = c(-3, 5), ylim = c(-3, 3))

x_fa = c(x_f, x_a)
y_fa = c(y_f, y_a)
z_fa = rbind(x_fa, y_fa)

plot(y_fa ~ x_fa, xlim = c(-1, 4), ylim = c(-3, 3))

R code to left multiply a square matrix (x) against each of the vectors of

points (y)

left_multiply <- function(x, y){
  result <- apply(y, 2, function(a) x %*% a)
  return(result)
}

Sheer

x11()
identity = diag(2)
for(i in seq(0, 1, length.out = 100)){
  identity[1, 2] = i
  transformed_matrix <- left_multiply(identity, z_fa)
  plot(transformed_matrix[2,] ~ transformed_matrix[1,], xlim = c(-1, 4), ylim = c(-3, 3))
}

Scale

x11()
identity = diag(2)
for(i in seq(0, 3, length.out = 100)){
  identity[1, 1] = i
  identity[2, 2] = i
  transformed_matrix <- left_multiply(identity, z_fa)
  plot(transformed_matrix[2,] ~ transformed_matrix[1,], xlim = c(-1, 9), ylim = c(-4, 4))
}

Rotation

x11()
rotation_matrix <- function(x){
  matrix(c(cos(x), -sin(x), sin(x), cos(x)), byrow=TRUE, nrow=2)
}
for(i in seq(0, 6.5, length.out = 100)){
  transformation <- rotation_matrix(i)
  transformed_matrix <- left_multiply(transformation, z_fa)
  plot(transformed_matrix[2,] ~ transformed_matrix[1,], xlim = c(-4, 4), ylim = c(-3, 3))
}

Projection

x11()
identity = diag(2)
for(i in seq(0, 3, length.out = 100)){
  identity[2, 2] = i
  transformed_matrix <- left_multiply(identity, z_fa)
  plot(transformed_matrix[2,] ~ transformed_matrix[1,], xlim = c(-1, 4), ylim = c(-3, 3))
}