The x-values are composed of repetitions of values 0 through 1 that correspond to the lines that make up an H along the x-axis. The y-values are composed of repetitions of values -1 through 1 that make up an H along the y-axis. The plot creates an H.
x <- c(rep(0,500),seq(0,1,length.out=1000), rep(1,500))
y <- c(seq(-1,1,length.out=500),rep(0,1000), seq(-1,1,length.out=500))
plot(y~x, xlim=c(-3,3), ylim=c(-3,3))
In this section, the same language is used to create the x and y values. However, the J requires a curve. To make the curve, values were squared and then transformed to the proper location. The plot then shows the finished product.
xJ <- c(seq(0,1,length.out=1000), seq(0,0.5,length.out=1000), rep(0.5,1000))
one <- seq(-1,1,length.out=1000)
two <- one**2 - 1
line <- seq(0,1,length.out=1000)
yJ <- c(rep(1,1000), two, line)
plot(yJ~xJ, xlim=c(-3,3), ylim=c(-3,3))
This section is very similar to making an H since all the lines are straight. The H was composed of three lines like the F, so the code only changes for the differences between the letters.
The length was shorter for xF and yF for no reason other than my interest in creating a vector zFinal that had a length with an integer square root.
xF <- c(rep(0,500), seq(0,1,length.out=908), seq(0,1,length.out=1000))
yF <- c(seq(-1,1,length.out=500),rep(0,908), rep(1,1000))
plot(yF~xF, xlim=c(-3,3), ylim=c(-3,3))
This shows my first and last initials plotted on one graph.
xFinal <- c(xJ, xF + 1.25)
yFinal <- c(yJ, yF)
zFinal <- rbind(xFinal, yFinal)
plot(xFinal, yFinal, xlim = c(-2,4), ylim=c(-3,3))
This section creates two matrices, one normal matrix and one identity matrix. I created a function called leftMultiple to do the left multiplication of any two matrices. The example below shows one matrix being multiplied by the identity matrix.
y1 <- matrix(1:16, nrow=4)
x1 <- diag(4)
leftMultiply <- function(x, y)
{
x %*% y
}
leftMultiply(x1, y1)
## [,1] [,2] [,3] [,4]
## [1,] 1 5 9 13
## [2,] 2 6 10 14
## [3,] 3 7 11 15
## [4,] 4 8 12 16
Below, you will see an animation where my initials are sheared to the left. They seem to turn into italics, but in the opposite direction of normal italics. The code turns the zFinal variable into two columns, one with x values and one with y-values. Then, the function created previously multiplies this matrix with the identity matrix that changes over time to make sure the letters are sheared. The plots are then displayed in order to display the change over time as the value of the top right row of the square matrix changes. A positive 1 value in the sequence of the for loop would shear the letters in the opposite direction.
for (i in seq(0,-1,length.out=20)) {
zMatrix<-apply(zFinal,2,function(x) leftMultiply(x,matrix(c(1,i,0,1),nrow=2,ncol=2)))
plot(zMatrix[2,]~zMatrix[1,], xlim=c(-2,4), ylim=c(-3,3), col='red')
}
This section shows how to scale the values up and down. The letters will expand and then shrink to normal size with the two for loops. The sizes change because the identity matrix is multiplied by various numbers from 1 to 2. As they increase, the size of the letters increases. As they decrease, the size of the letters decreases. This happens because the x and y values of the letters are all multiplied by the value of “i”.
for (i in seq(1,2,length.out=20)) {
newZ<-apply(zFinal,2,function(x) leftMultiply(x,matrix(c(i,0,0,i),nrow=2,ncol=2)))
plot(newZ[2,]~newZ[1,], xlim=c(-2,6), ylim=c(-3,3), col='red')
}
for (i in seq(2,1,length.out=20)) {
newZ<-apply(zFinal,2,function(x) leftMultiply(x,matrix(c(i,0,0,i),nrow=2,ncol=2)))
plot(newZ[2,]~newZ[1,], xlim=c(-2,6), ylim=c(-3,3), col='red')
}
This section rotates the letters. It uses sine and cosine to rotate them. To change the direction of the rotation, the negative value can be moved to a different location in the square matrix.
for (i in seq(0,10,length.out=40))
{
zRotate<-apply(zFinal,2,function(x) leftMultiply(x,matrix(c(cos(i),-sin(i),sin(i),cos(i)),nrow=2,ncol=2)))
plot(zRotate[2,]~zRotate[1,], xlim=c(-2,4), ylim=c(-3,3), col='red')
}
In this section, one projection is shown. This is a projection across the x-axis. The x-axis acts as a plane for reflection. The letters are slowly reflected across the x-axis.
for (i in seq(0,10,length.out=30))
{
zPartTwo<-rbind(zFinal,rep(0,ncol(zFinal)))
zNewest<-apply(zPartTwo,2,function(x) leftMultiply(x,matrix(c(1,0,0,0,sin(i),cos(i),cos(i),sin(i),0),nrow=3,ncol=3)))
plot(zNewest[2,]~zNewest[1,], xlim=c(-3,3), ylim=c(-3,3), col='red')
}