ypag

10 Feb 2015

Twitter Text: Using growth algorithms to create insect wings.

My inspiration comes from insect wings.
Wing-insect

The veins form a peculiar pattern. I was initially lost to understand how to create these patterns. One idea was to hardcode the 8 main veins of a wing and then divide these veins further in lines with reduced lengths. That would’t have been parametric and also the next segment could be at any angle.
This is when I came across about L system in python. I tried to get the L system package work with Rhinopython, but it did not work out. Further, I came across growth functions on this site, which turned out to be a great resource for learning rhinopython. I have borrowed DLA algorithm from this site.

I have created multiple wing like patterns, which grow on a base surface so that it can be printable.

pattern
This one looks like a leaf.

pattern1

pattern2
Face of an insect- do you see two eyes and mouth?

This page by nervous system was very helpful in understanding what Diffused Aggregation Functions (DLA) are and how to write one. I understood the concept of seeds (Thanks to Madeline here) to create better growth patterns. To create above patterns I have changed the array of points and not used any advanced seed methods.

My files is 148 MB, which is way larger than sketchfab
‘s 50 MB upload limit. Hence can not provide a 3D link here.
Render of the last pattern I created:

Screen Shot 2015-02-10 at 1.04.01 AM

wings2

Code is here:

 
import rhinoscriptsyntax as rs
import random
 
def placePt(x_range,y_range,z_range):
    x = random.randrange(0,x_range,2)
    y = random.randrange(0,y_range,2S)
    z = random.randrange(0,y_range,2)
    pt = [x,y,z]
    return pt
 
rs.EnableRedraw(False)
 
ptZero = [100,250,50]
pts = []
pts.append(ptZero)
#circleZero = rs.AddCircle(ptZero,0.5)
sphereZero = rs.AddSphere(ptZero, 0.4)
 
 
 
for i in range(0,400):
    pt = rs.AddPoint(placePt(100,100,100))
    index = rs.PointArrayClosestPoint(pts,pt)
    cp = pts[index]
    vect = rs.VectorCreate(cp,pt)
    unitVect = rs.VectorUnitize(vect)
    subVect = vect - unitVect
    newPt = rs.MoveObject(pt,subVect)
    #rs.AddCircle(newPt,0.5)
    rs.AddSphere(newPt,0.5)
    pts.append(newPt)
 
rs.Redraw()