library("gifski")
library("gganimate")
## Loading required package: ggplot2
First letter initials are K and G.
x=c(rep(-1,800),seq(0,-1,length.out=800), seq(0, -1, length.out = 800), seq(2,1, length.out = 800), rep(1, 800), seq(1,2, length.out = 800), seq(1.5,2, length.out = 800), rep(2, 800))
y=c(seq(2,-1,length.out=800),seq(-1, 0.5, length.out = 800), seq(2,0.5,length.out=800), rep(2,800), seq(2,-1, length.out = 800), rep(-1,800), rep(0, 800), seq(0,-1, length.out = 800))
z=rbind(x,y)
plot(y~x,xlim=c(-3,3),ylim=c(-3,3))
leftMultiply <- function(x, y){
x%*%y
}
leftMultiply(matrix(rep(seq(1,3, length.out=3),3), nrow = 3, ncol = 3),diag(3))
## [,1] [,2] [,3]
## [1,] 1 1 1
## [2,] 2 2 2
## [3,] 3 3 3
for (i in seq(0,4,length.out=20)) {
newZ<-apply(z,2,function(x) leftMultiply(x,matrix(c(1,i,0,1),nrow=2,ncol=2)))
plot(newZ[2,]~newZ[1,], xlim=c(-3,3), ylim=c(-3,3))
}
for (i in seq(0,4,length.out=20)) {
ext_z <- rbind(z, numeric(800))
trans_matrix <- matrix(c(i,0,0,0,1,0,0,0,1), nrow=3, ncol=3)
tm <- apply(ext_z, 2, function(x) x %*% trans_matrix)
plot(tm[2,] ~ tm[1,], xlim=c(-3,3), ylim=c(-3,3))
}
for (i in seq(0,pi*2,length.out=20)) {
newZ<-apply(z,2,function(x) leftMultiply(x,matrix(c(cos(i),-sin(i),sin(i),cos(i)),nrow=2,ncol=2)))
plot(newZ[2,]~newZ[1,], xlim=c(-3,3), ylim=c(-3,3))
}
for (i in seq(0,2*pi,length.out=20)) {
triZ<-rbind(z,rep(0,ncol(z)))
newZ<-apply(triZ,2,function(x) leftMultiply(x,matrix(c(1,0,0,0,cos(i),-sin(i),0,sin(i),cos(i)),nrow=3,ncol=3)))
plot(newZ[2,]~newZ[1,], xlim=c(-3,3), ylim=c(-3,3))
}