Archive for the ‘Recursion’ Category

colaboration / flying surface

Friday, June 26th, 2009

This is a small colaboration with Mary ann busby, from chile.
the aim was generate surface from other surfaces, and create some kind movement.
the code works under recursion: analizing, generating and deleting every surface.
is very abstract and also is very simple how it’s works.

This movie requires Flash Player 9

Some Images from the complete generation, saving every “child”:

113

27

2-a-despues-del-crecimiento

35

r22

r12

r3-seccion-de-un-crecimiento

r21

And here the code:
some functions from Marius Watz:
Option Explicit
‘Script written by carlos de la b.
‘Script copyrighted by designemergente.org
‘Script version miércoles, 24 de junio de 2009 18:17:12

Call Main()
Sub Main()

‘//we need a Surface to grow and grow
Dim Idsrf
Idsrf = Rhino.GetObject(”sel srf”, 8)
If IsNull(Idsrf) Then Exit Sub

Call rec(Idsrf, 0)

End Sub

Function rec(Idsrf, counter) ‘//recursion under your own Risk!!!

‘domain of the curve
Dim Udom, Vdom
Udom = Rhino.SurfaceDomain(Idsrf, 0)
Vdom = Rhino.SurfaceDomain(Idsrf, 1)

‘parameters, divisions, counters and a point
Dim Up, Vp, divU, divV, i, j, k, pt, l
k = 0
divU = 6
divV = 6

Dim arrPoints(35)

For i = 0 To divU – 1
For j = 0 To divV – 1

Up = Udom(0) + i * ((Udom(1) – Udom(0)) / divU)
Vp = Vdom(0) + j * ((Vdom(1) – Vdom(0)) / divV)

pt = Rhino.SurfaceCurvature(Idsrf, Array(Up, Vp))

‘Randomize
‘ If 0.5 < rnd Then
‘ pt(1) = Rhino.VectorScale(pt(1), rnd * 5)
‘ l = Rhino.PointAdd(pt(1), pt(0))

‘ Else
l = Rhino.PointAdd(pt(1), pt(0))

‘ End If

arrPoints(k) = l
k = k + 1

Next
Next

Call Rhino.DeleteObject(IDsrf)
Dim n: n = Rhino.AddSrfPtGrid (Array(divU, divV), arrPoints)

Call Rhino.sleep(3000)

renderView()

Call rec(n, counter + 1)

End Function

‘ Render current viewport
Function renderView()’this function from Marius Watz, a very little modification by me.
Dim view,filename

view = Rhino.CurrentView
Rhino.Command “_-Render”
filename=getRenderFileName(”GrowSurface”)
Dim cmd : cmd=”_-SaveRenderWindowAs ” & Chr(34) & filename & Chr(34)
Rhino.Command cmd
Rhino.Command “_-CloseRenderWindow”
Rhino.Sleep(3000)
End Function

‘ Get auto-incremented filename
Function getRenderFileName(scriptName) ‘this function from Marius Watz
Dim index,done, doc, file, temp,imgNum

done=-1
index=0
Do While done=-1
doc=Rhino.WorkingFolder & “\” & scriptName & padStr(scriptName,index) & “.jpg”
file=Rhino.FindFile(doc)
If IsNull(file)=True Then
done=1
Else
index=index+1
End If
Loop

getRenderFileName=doc
End Function

Function padStr(prefix,val) ‘this function from Marius Watz
Dim l : l=Len(val)
If l<1 Then
padStr=”000″ & val
ElseIf l<2 Then
padStr=”00″ & val
ElseIf l<3 Then
padStr=”0″ & val
Else
padStr=”" & val
End If
End Function

Workshop RhinoScript at ETSAM(Madrid)

Monday, April 20th, 2009

The last week I have been teaching at ETSAM in Madrid, doing a RhinoScript Workshop in GIGA  Departamento de Ideación Gráfica. Most of the Participants are professors of the university with high levels of mathematics and geometry. The rest, students with high levels in scripting (VB and processing). The workshop lasted two days, we start with Data Types, Mathematical Operations, Conditionals, Loopings, Arrays, Functions and Advanced Functions, Curves Analisys, Surface Analysis, Generation of Surfaces by Parametric Equations (in the group we count with a mathematician), Fractals and Recursion.

The atmosphere during the workshoop was really cool!. I would personally like to thank: Carmen García Reig (Organization and invitation), Ismael García (Organization), Antonio Casas (the mathematician), Pablo Miranda Carpintero (I’m eager to see the programming in Sketch-up), Tomás Pineda (Images), Miguel Vidal, see his blog: arquitecturaprogramable.es

With no particular order, some images of the projects during the workshop.




Tomás Pineda:

tomas4

tomas3

tomas2

tomas1




Pablo Miranda

pablo4

pablo3

pablo2

pablo1




Miguel Vidal

miguel8

miguel7

miguel6

miguel5

miguel4

miguel3

miguel2

miguel1




Ismael García

ismael4

ismael3

ismael2

ismael1




Carmen García Reig

carmen3

carmen2

carmen9

carmen8

carmen7

carmen6

carmen5

carmen4

What I did in SFO (SG’09)

Friday, April 10th, 2009

This was my first time in an SmartGeometry, and I was impressed the high level of the participants and tutors.

Truss Optimization Trough Excel

Mi proposal for the workshop (4 days) consisted in optimize a steel truss, reducing the total weight of the steel, changing thier geometry. but constrained some nodes of the truss move in determinated zones. My original idea for the optimizatión was use Genetic Algorithms.  but in the workshop they propose me use the SOLVE program of Excel to optimize the truss.

This Image Show the description of the problem

carlos-de-la-barrera1



This Image  show the relation between GC and Excel how excel Manage the Geometry into GC. Also explain where in excel is the goal (the number that we are trying to reduce). The loads in the truss is decomposed node by node using the trignometric function Sin and Cos. fortunly for me the most part of the excel spreadsheet was maded by Matthew Clark from Arup New York. and the Strategy to connect both programms was of Steven Downing also from Arup Australia.

I Adde the constraints zone into excel and connect them to the position of the points also in the spreadsheet. the code in GC is really short but very intelligent because gc is completely camptured by Excel.

carlos-de-la-barrera12




In this image there are an screenshot of the Solver in excel and the truss before and after the optimization. this Images were prepared for the conference day.

carlos-de-la-barrera13




This are the parameters of the solver into Excel. also there are more options that you can control like the number of the iterations, the type of the algorithm to optimize, the accurate, etc.

optimization-window




This is an Screenshot during my work.

op_1copy




This is another screenshot and show the truss and the zones where the nodes can be moved. The width difference among all the tubes depends of the section area. also calculated from the spreadsheet in excel.

op_1




The truss with differents settings and extreamly constraints in the nodes. th truss now is calculated completely in compression, the reason becasuse all the tubes are in red color.

model-with-settings




now the truss is calculated and new loads are defined. blue colors represent that this tubes are working to the slenderness.

model-before-optimization-and-settings

And here after tthe optimization.

model-after-the-optimization

sketches in my notebook.

ideas_2

ideas

Here the constraints for each node.

conditional-study

And this is a video of the process.

Seminario AGs – U.P.C.

Wednesday, December 17th, 2008

Después de todos estos meses trabajando para el doctorado, las diferentes colaboraciones para ACXT, concursos con amigos (casi nunca puedo decir que no), la preparación de mis clases para la universidad, El curso del FIB sobre Redes Neuronales y computación evolutiva me han dejado muy poco tiempo. Y cuando lo he tenido, lo he empleado en limpiar los platos. Creí ver una civilización que había desarrollado inteligencia, había dividido el lavaplatos y se preparaban para una guerra con migas de pan.

Hago este post, de un pequeño seminario para profesores de la UPC, sobre Algoritmos Genéticos. Todos ellos sabían programar desde hace mucho. Habían comenzado con Auto Lisp para Auto CAD y eran muy hábiles con Visual BASIC, obsesionados con las nubes de puntos y el apilamiento de bloques.
Todos locos de la investigación y la exploración.
El Seminario fue muy corto, pero tuvimos oportunidad de intercambiar muchas ideas y estrategias en resolución de algoritmos y en la optimización de diferentes problemas.

Un ejercicio muy interesante fue el ByteString Problem, que comenzamos usando la fuerza bruta para descifrar una cadena de N bytes. Para luego poder incorporar estrategias evolutivas y poder comparar las diferentes estrategias.

Todas las imagenes tomadas de la web: google / imagenes / “parámetro de búsqueda”.
excepto imagen 9, cuaderno de notas, autor
excepto imagen 10, esquema básico de los AGs, autor
excepto imagen 20, funciones del ByteString Problem, autor, curso de Luis Belanche
excepto imagen 21, print pantalla de un resultado de búsqueda por medio de mutacion, población y descendencia, se uso RhinoScript, aunque VB dio algunos problemas fueron solucionados.
Excepto Imagen 25, estrategia tomada de http://www.geocities.com/pretabbed/ags.htm
























Cellular Automaton

Sunday, May 25th, 2008