If it's hard to express your love for someone, do it mathematically!

I know, it’s not always easy to express your love for someone. However, today is a “special” day so lets do it mathematically (using the programming language R).

Happy Valentine’s Day!

.. and here’s the code if you want to produce your own Valentine’s picture/video. Feel free to use it!

t <- seq(-10,10,0.01)
x <- 16*sin(t)^3
y <- 13*cos(t) - 5*cos(2*t) - 2*cos(3*t) - cos(4*t)
op = par(bg = 'black', mar = rep(0.5, 4), col = "white")

# Code for picture
plot(y = y, x = x, col = "red", pch = 16)
text(y = min(y), x = max(x)-2, labels = "© Arian Barakat")


# Use the following code if you want to create an animation

library(animation)

saveVideo({
  for(i in 1:length(t)){
    op = par(bg = 'black', mar = rep(0.5, 4), col = "white")
    plot(y = y[1:i], x = x[1:i], col = "red", pch = 16)
    text(y = min(y), x = max(x)-2, labels = "© Arian Barakat")
  }
},
interval = 0.03,
video.name = "/path/to/file/heart.mp4",
ani.width=800,
ani.height=800
)
Arian Barakat

Arian Barakat

rss facebook twitter github youtube mail spotify instagram linkedin google google-plus pinterest medium vimeo stackoverflow reddit quora