-
Notifications
You must be signed in to change notification settings - Fork 0
Home
pseandersson edited this page Apr 2, 2016
·
4 revisions
The lsystem repository provides a simple implemntation of Lindermayer System, or L-System in python. L-System's are commonly used to create procedural geometries such as trees and plants and could be utilized to much more. The python code is developed upon the NumPy and pyglet python-libraries, where the first is to make simple math operations and the latter is for visualization.
import lsystem as ls
import turtle as t
import numpy as np
import string
from lviewer import *
X0 = np.array([0,0,0])
R0 = np.eye(3)
stepsize=0.1
delta = 22.5
dr = 0.001
r0 = 0.01
generations = 7
instr = 'A'
rules = {
'A':'[&FL!A]/////\'[&FL!A]//////\'[&FL!A]',
'F':'S ///// F',
'S':'F L',
'L':'[\'\'\'^^{-f+f+f-|-f+f+f}]'
}
itree = ls.resolve_instructions_by_tree(instr,rules,generations)
turtle = t.turtle_tree(itree,X0,R0,r0,stepsize,delta,dr)
print 'Done!'
draw_turtle(turtle)
- Simple L-System (F->F+fF-fF-)
- Subscription support (F_L->F_R+F_L)
- Figures (L->LRLRLR)
- Branching (F->FF[+F+F])
- 3-Dimensional
- Polygons (FFff{fff-ff-f})
- Stochastic rules (F-prob0.5->FF[+F+F+F]; F-prob0.5->FF[-F-F-F])
- Conditional (a< b > c -> ABC)
- Parametric description (A(x,y):x+y>0->A(x+1,y0.5)F(0.5(x+y))
- View-manipulator (zoom, rotate,pan)
- Lines, Polygon
- Tesselation of L-System
- UV/Material
- Export to Alembic
- Animation