One of the most useful applications for linear algebra in data
science is image manipulation. We often need to compress, expand, warp,
skew, etc. images. To do so, we left multiply a transformation matrix by
each of the point vectors.
For this assignment, build the first letters for both your first and
last name using point plots in R. For example, the following code builds
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))
z=rbind(x,y)
plot(y~x, xlim=c(-3,3), ylim=c(-3,3))
x=c(seq(-2,-1,length.out = 200),rep(-1,100),seq(-1.5,-0.5,length.out = 100))
y=c(rep(-1,200),seq(1,-1,length.out = 100),rep(1,100))
z=rbind(x,y)
plot(y~x, xlim=c(-3,3), ylim=c(-3,3))
x0=c(rep(1,100),seq(1,1,length.out=100),seq(2,1,length.out=100),rep(1,200),seq(2,1,length.out =100),rep(2,100),seq(2,2,length.out = 100))
y0=c(seq(1,-1,length.out=100),rep(1,100),seq(-1,1,length.out=100),rep(1,200),seq(-1,1,length.out =100),seq(1,-1,length.out = 100),rep(1,100))
z0=rbind(x0,y0)
plot(y0~x0, xlim=c(-3,3), ylim=c(-3,3))
x1=c(seq(-2,-1,length.out = 200),rep(-1,100),seq(-1.5,-0.5,length.out = 100)
,rep(1,100),seq(1,1,length.out=100),seq(2,1,length.out=100),rep(1,200),seq(2,1,length.out =100),rep(2,100),seq(2,2,length.out = 100))
y1=c(rep(-1,200),seq(1,-1,length.out = 100),rep(1,100)
,seq(1,-1,length.out=100),rep(1,100),seq(-1,1,length.out=100),rep(1,200),seq(-1,1,length.out =100),seq(1,-1,length.out = 100),rep(1,100))
z1=rbind(x1,y1)
plot(y1~x1, xlim=c(-3,3), ylim=c(-3,3))
matrices <- list(list( cbind( c(1,0), c(1,1) ),"Shear"))
for( m in matrices)
{
plot(t(m[[1]] %*% z1), main = m[2], xlim=c(-3,3), ylim=c(-3,3))
plot.new()
#quartz()
}
matrices <- list(list( cbind( c(1,1), c(1,0) ),"Rotation"))
for( m in matrices)
{
plot(t(m[[1]] %*% z1), main = m[2], xlim=c(-3,3), ylim=c(-3,3))
plot.new()
#quartz()
}
matrices <- list(list( cbind( c(0,0), c(0,1) ),"Projection"))
for( m in matrices)
{
plot(t(m[[1]] %*% z1), main = m[2], xlim=c(-3,3), ylim=c(-3,3))
plot.new()
#quartz()
}