Skip to content

Instantly share code, notes, and snippets.

@cmckni3
Last active August 29, 2015 14:04
Show Gist options
  • Save cmckni3/67ae40b0bd888615ded9 to your computer and use it in GitHub Desktop.
Save cmckni3/67ae40b0bd888615ded9 to your computer and use it in GitHub Desktop.
speed <- 55
distance <- 2
speeds <- seq(54, 0)
h <- function(x) ceiling((distance / (speed - x)) * 3600)
g <- Vectorize(h)
times = g(speeds)
plot(speeds,times, xlim=c(54, 0), xlab="speed (mph)", ylab="time (s)", col="red")
smoo<-spline(speeds,times)
lines(smoo$x,smoo$y)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment