-shapes <- function(num, iter){
- basex[i] = 10 * cos(2 * pi * i / num)
- basey[i] = 10 * sin(2 * pi * i / num)
- iterx[1] <- runif(n = 1, min = min(basex), max = max(basex))
- itery[1] <- runif(n = 1, min = min(basey), max = max(basey))
- pick <- ceiling(runif(n = iter, min = 0, max = 1) * num)
- iterx[i] <- iterx[(i-1)] + ((basex[pick[i]] - iterx[(i-1)]) * ((num - 2) / (num - 1)))
- itery[i] <- itery[(i-1)] + ((basey[pick[i]] - itery[(i-1)]) * ((num - 2) / (num - 1)))
- start_points <- data.frame(x = basex, y = basey)
- iter_points <- data.frame(point = (1:iter), x = iterx, y = itery)
-triangle <- shapes(3, 2500)
-square <- shapes(4, 2500)
-pentagon <- shapes(5, 2500)
-tri <- ggplot(triangle, aes(x = x, y = y)) +
-sq <- ggplot(square, aes(x = x, y = y)) +
-penta <- ggplot(pentagon, aes(x = x, y = y)) +