Skip to content

Instantly share code, notes, and snippets.

View marcusvolz's full-sized avatar

Marcus Volz marcusvolz

View GitHub Profile
@marcusvolz
marcusvolz / wildflowers.R
Created April 5, 2020 10:28
Wildflowers
# Load packages
library(generative) # devtools::install_github("marcusvolz/generative")
library(ggplot2)
for (i in c(3, 86, 111)) {
# Set parameters
seed <- i
set.seed(seed)
n <- 400
n_circles <- 4 # 4
@marcusvolz
marcusvolz / procedural_ring_generator.R
Created April 1, 2020 10:36
Procedural ring generator
# Load packages
library(generative) # install_github("marcusvolz/generative")
library(tidyverse)
# Create lots of plots
for (i in 1:200) {
# Set paramter values
set.seed(i)
r_0 <- runif(1, 0, 1000) # 15000
eps <- runif(1, 0, 500) # 550
@marcusvolz
marcusvolz / shell_1531.R
Created March 26, 2020 09:17
Shell 1531
# The shell math model is from the paper by M.B. Cortie (1989)
# https://www.researchgate.net/publication/238757952_Models_for_mollusc_shell_shape
# Load packages
library(mathart) # devtools::install_github("marcusvolz/mathart)
library(tidyverse)
# Set parameters (see mathart::mollusc() documentation for details)
n_s <- 650L
n_t <- 2000L
@marcusvolz
marcusvolz / butterfly_knn.R
Last active June 28, 2021 16:36
Butterfly knn
# The curve is a generalisation of the butterfly curve (Fay, 1989)
# See the Wiki for details: https://en.wikipedia.org/wiki/Butterfly_curve_(transcendental)
# Load packages
library(mathart) # devtools::install_github("marcusvolz/mathart")
library(tidyverse)
# Set parameters
n <- 1000
a <- 2
@marcusvolz
marcusvolz / interpolate_squares.R
Created March 24, 2020 08:43
Interpolate squares
# Load packages
library(generative) # devtools::install_github("marcusvolz/generative")
library(ggplot2)
# Generate data (see generative::interpolate_squares documentation for details)
df <- interpolate_squares(seed = 1, n = 25, ease_function = "")
# Create plot
p <- ggplot() +
geom_segment(aes(x, y, xend = xend, yend = yend), df, alpha = 0.03,
@marcusvolz
marcusvolz / procedural_ring.R
Last active June 28, 2021 16:28
Procedural ring
# Load packages
library(generative) # devtools::install_github("marcusvolz/generative")
library(ggplot2)
# Set parameters (see generative::procedural_ring documentation for details)
seed <- 3
n <- 400
n_circles <- 4
r_0 <- 500
eps <- 500
@marcusvolz
marcusvolz / rose_knn.R
Last active June 28, 2021 16:37
Rose curve k-nearest neighbour graph
# Load packages
library(mathart) # devtools::install_github("marcusvolz/mathart")
library(tidyverse)
# Set parameters
# Rose curve wiki: https://en.m.wikipedia.org/wiki/Rose_(mathematics)
# Nearest neighbour graph wiki: https://en.m.wikipedia.org/wiki/Nearest_neighbor_graph
n <- 9
d <- 8 # Note: k = n/d is a curve parameter
N <- 11 # Controls the total curve length