gif

library(animation)


myani=ani.record(reset = TRUE, replay.cur = FALSE)
dev.control('enable')
par(bg = "white")


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

##Scale

for(i in 1:10) {
  scaleMatrix <- matrix(c(i,0,0,i),nrow=2, ncol=2,byrow = TRUE)
  scale <- scaleMatrix %*% z
    m <- scale[2,]
    n <- scale[1,]
    
  
  
  
}




##Rotate

for(i in 1:20) {
  
  rotateMatrix <- matrix(c(cos((pi/8)*i), -sin((pi/8)*i), sin((pi/8)*i), cos((pi/8)*i)),nrow=2, ncol=2,byrow = TRUE)
  rotation <- rotateMatrix %*% z
  m <- rotation[2,]
  n <- rotation[1,]
  
 
 
  
}

##Shear

for(i in 1:30) {
  shearMatrix <- matrix(c(1,i*.02,0,1),nrow=2, ncol=2,byrow = TRUE)
  shear <- shearMatrix %*% z
  m <- shear[2,]
  n <- shear[1,]
       
  
  
       
     }

##Projection

for(i in 1:30) {
  projectionMatrix <- matrix(c(1,0,0,.2*i),nrow=2, ncol=2,byrow = TRUE)
  projection <- projectionMatrix %*% z
  m <- projection[2,]
  n <- projection[1,]
  
  
  
  
}