Rossler Attractor Python Script in Grasshopper3d

Looking more into Python, the syntax and how you can use for loops, Rhinocommon and math within the GH Python Component, I decided to write and share this animated Python script of a Rossler attractor.  This particular attractor lies in the context of particle kinematics within chemical reactions. This system is defined by three non-linear ordinary differential equations originally studied by Otto Rössler. I find it to be, an extremely interesting and minimally beautiful system, mainly due to the particle’s easily observed movement in the Cartesian 3D space.

rosslers002

ros006

Thy python code looks something like this:

#”Rossler Attractor Grasshopper Python Component”
#Written by Marios Tsiliakos on 22/11/2012
#Based on the equations provided by Paul Bourke http://paulbourke.net
#Rossler Attractor by Marios Tsiliakos is licensed under a
#Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.
#Based on work at http://www.digitalsubstance.wordpress.com.
#Imports
from math import *
import _random as rnd
import Rhino
# Subfunction
def Rossler(it):
#random number
r=rnd.Random(Seed)
r0 = r.random()*0.1
# set the constants
a = 0.15 + r0
b = 0.2 – r0
c = 5.7 + r0
h = H
var.append((round(a,2),round(b,2),round(c,2)))
# provide the initial point
x,y,z=0.1,0.0,0.0
for i in range(it):
x0= x + h*(-y -z)
y0= y + h*(x + a*y)
z0= z + h*(b+z*(x-c))
#make the resulting coordinates the coordinates last point
x,y,z = x0, y0, z0
pts= Rhino.Geometry.Point3d(x,y,z)
arrPts.append(pts)
#Main function
if Iterations == None:
Iterations = 1000
if H == None:
H = 0.05
if Seed == None:
Seed = 2
if Run== True:
#global lists
arrPts = []
var =[]
# always provide the creation of a curve by sufficient number of points
numpoints =counter+4
if numpoints < Iterations:
Rossler(numpoints)
crv = Rhino.Geometry.Curve.CreateInterpolatedCurve(arrPts,3)
counter+=10
print counter
print “Rossler attractor with values: a =” , var[0][0],”b=” , var[0][1],”c=”, var[0][2],”h=” , H
if numpoints >= Iterations:
print “goal achieved”
# Comment out the next line to get the resulting points
#Rossler(Iterations)
#crv = Rhino.Geometry.Curve.CreateInterpolatedCurve(arrPts,3)
#counter = Iterations
#outputs
Ross=crv
Points = arrPts
else :
print(“Idle”)
counter = 0

And here is a snapshot of the definition . You can download it at the usual place.

Enjoy!

Advertisements

TetraAggregationV2.0 | Aggregating Systems using Hoopsnake for Grasshopper3d

[vimeo http://vimeo.com/38565641 w=620&h=341]

This is a follow-up to my last post on tetrahedral morphing using Grasshopper3d and some VB.net. I implemented this process into a recursive methodology using the Hoopsnake Component for GH developed by Yiannis Chatzikonstantinou, in order to put together a dynamically growing system. The process utilizes a method similar to DLA (Diffuse Limited Aggregation) with the significant difference of being sustained in only one face of the tetrahedron each time. This way the  aggregated geometry remains non self-intersecting. The results of this process are quite interesting mostly because of the emergent characteristics of the recursion .

You can grab the code from here.

Enjoy!

L-Systems Tree in Processing [Recursive Branching]

recursive_tree_rendered

I started playing around with a code i have written last year based on the prototype of  Alasdair Turner’s Recursive tree ( you can find it here). I added a few snapshots of the algorithm which operates in a recursive manner adding new branches into parent ones. There is however a parametric control over the variables, such as the number of generations, the  mutation rate, the size and width of the branch all integrated in an associative procedure + a randomness that provides a large amount of interesting results. I might be posting the code soon , as long as I work it a little bit more and reinforced it with some commenting ( boring….). I really look forward implementing a phototropic character into the algorithm, affecting its organization and hierarchy through the sun’s position..

tree1

 

tree3

tree4