Skip to content

Instantly share code, notes, and snippets.

@cavedave
Last active March 4, 2016 22:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cavedave/67a371f7b492c44ebb2a to your computer and use it in GitHub Desktop.
Save cavedave/67a371f7b492c44ebb2a to your computer and use it in GitHub Desktop.
# library documentation at https://cran.r-project.org/web/packages/LindenmayeR/LindenmayeR.pdf
# L systems described here at https://en.wikipedia.org/wiki/L-system
#variables : X Y
#start : FX
#rules : (X → X+YF+), (Y → −FX−Y)
#constants : F + −
#angle : 90°
# This doesnt work
library(LindenmayeR)
rSierp <- data.frame(inp = c("X", "Y"), out = c("X+YF+", "-FX−Y"), stringsAsFactors = FALSE)
s <- Lsys(init = "FX", rules = rSierp, n = 10)
dSierp <- data.frame(symbol = c("X", "Y", "F","+", "-"),
action = c("f", "F", "F","+", "-"), stringsAsFactors = FALSE)
drawLsys(string = s, stepSize = 1, ang = 90, st = c(20, 25, 0), drules = dSierp)
grid.text("Dragon (n = 6)", 0.5, 0.1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment