Circle Packing

Aug 20, 2008 / Comments (0)

I’ve been working yesterday in a Circle Packing, and I started with matsys pseudo-code.  I found a lot bugs, finally I decided to make a mixture between his algorithm and mine.  Circle Packing can be a very usefull algorithm and I think until now we have not seen their real power applied to architecture.

This is my little contribuition (pseudo_Code)

1_ Input: maxradius, boundary, iterations (not necessary the number of circles)

2_Add in a random position within the boundary a circle with maximum radius

3_Add a Random Point

4_If this Point is inside of the Circle just created, add another one and delete the old one

5_Add Line to this point (out of the circle) to the center of the circle, (here I use the same idea of matsys) “If the distance is greated than the maximum radius add a circle at that point with the maximum radius. If the distance is less than the maximum radius, add a circle at that point with the measured distance.”

6_ add another point and test if this point is within of any circle and add a line to every center circle to find the closest circle (step _5)

7_ repeat the steps 5  to 6 the number of the iterations

soon more images.

share, modify and send me an Image

best

Option Explicit
‘Script written by <Carlos de la Barrera>
‘Script copyrighted by <Carlos de la Barrera>

Call Main()
Sub Main()
Dim Pt, R
Pt = Array(rnd * 100, rnd * 100, 0)
R = FuncCir(Pt, 10)

Call Pack(R)
End Sub

Function Pack(R)
Dim Pt, i, count

count = Rhino.GetInteger(” number of circles “, 50, 2, 1000)
If IsNull (count) Then Exit Function

Dim ArrData()

For i = 0 To count
ReDim Preserve ArrData(i)
ArrData(i) = R

Pt = Array(Rnd * 100, rnd * 100, 0)

Dim j
Dim t: t = 0

For j = 0 To UBound(ArrData)
If Rhino.IsPointOnSurface(ArrData(j)(1)(0), Pt)Then
Call Rhino.print (”point in surface”)
t = t + 1

End If
Next

If (t = 0) Then
ReDim ArrLine(UBound(ArrData))
Dim k, line

For K = 0 To UBound(ArrData)
line = Rhino.AddLine(Pt, Rhino.CircleCenterPoint(ArrData(k)(0)))
ArrLine(k) = Line
Next

Dim d, d2, l
d = funcDist(Pt, ArrData(0)(0), ArrLine(0))

For l = 0 To UBound(ArrLine)
d2 = funcDist(Pt, ArrData(l)(0), ArrLine(l))

If d < d2 Then
‘Call Rhino.Print (”nothing”)

Else
d = d2

End If
Next

R = FuncCir(Pt, d)
Call Rhino.DeleteObjects (ArrLine)

End If
Next
End Function

Function FuncCir(p, D)

If D >= 10 Then
D = 10

End If

Dim plane
Dim R(1)

plane = Rhino.PlaneFromFrame(p, Array(1.0,0.0,0.0), Array(0.0,1.0,0.0))
R(0)   = Rhino.AddCircle(plane, D)
R(1) = Rhino.AddPlanarSrf(Array(R(0)))

FuncCir = R
End Function

Function funcDist(Pt, circleP, Line)
Dim Ap, j, d
Ap = Rhino.CurveCurveIntersection (circleP, Line)

For j = 0 To UBound(Ap)
d = Rhino.Distance(Pt, Ap(j, 1))
Next

funcDist = d
End Function

the other day I listen: - talk it’s easy,  ¡ show me the code ! -

I was invited to paticipate in a contest to the Comune di Prato in Italy. I have to say thank you to this cool group of architects from Lisboa: Duarte Cardoso Ferreira, Nuno Lobo Guerra, Ricardo Boaventura, Rita Frias Silva from ADOC architects and all the team of 4ARQ encharged of the 3D images.

I was encharge to develope by programming the plans and the general features of the school. We start working identify every tree in the ground and the area of the differents rooms for the school. Every tree was identify by a point and a minum area of influence (in the fisrt step of the algorithm) and each area of the room of the school was enter in to the algorithm to know the best performance of the build with out touch any tree.

Then the algorithm calculate a voronoi diagram (only with the trees) and inform the resultant areas and we could see where can “grow” our building. the next step was develope a second algorithm to generate pseudo-random points, between the trees and responding obviously to the influence area of them.

Then the process consist basicaly in create generations and test the results, if the dispositions of points allow build the school (first and more important test), if the result produce nice spaces, if we like it, if the algorithm respect entrance determined by us, etc. etc. after every generation, we pass again this second algorithm to produce in some points a random movement to explore new configurations and results.

I take this idea from Mutsuro Sasaki, he use an strategy based in the approach in successive steps to get the best result moving the points in pseudo random way.

For me sometimes it is more difficult speak or write about my work that write the code in the editor. This images represent my eagerness that I had to translate this textile pattern, in to the code. so this is it.

Thi first step was to find the correct data store to find the points. then I put all this points inside of an array and then create the curve. and for the other curves I did the same, searching the even and odd of every point.

I know there are a lot kind of patterns in the textile insdustri, and also my Grandmother know how to create with the crochet technics differents patterns, some of them with very complex estructures. If we thought that an algortihm is and a mathematic or aritmetic rule that is repeated, (Cecil Balmond, Informal, page 112), we will see that my grandmother and all the people who elaborate knitted fabric are actually programming an Algortihm.

Genr8

Feb 24, 2008 / Comments (0)

Genr8 is a plug-in for maya and works generating surfaces. It is very interesting because fuse the universal growth conditions with evolutionary search.

Genr8 it is developed via API of Alias|WaveFront’s and Combine 3D Map L-System that growth in a digital environment, with gramatical evolution. the seed is designed to react of the digital nature and give to the user the control during the evolutionary adaptation, Genr8 dosen’t have structural or material criteria, and the most of the times the results are closer to the chaos.

Genr8 was Developed by Martin Hemberg and Una - May O’reilly and the people of the Emergent Design Group from the MIT.

salida6.jpg

Genr8 has a lot of components to create and evolve differents elements, like curves and surfaces.

Attractors, > act attracting surfaces.

Repellors, > similar like attractor but in a oposite way.

Gravity, > as it`s name, act in an uniform way in the global coordinates (x, y, z)

Boundaries, > you can create boxes, surfaces, to act like boundaries of the growth.

Seeds, > the seed by default it is a regular polygon, and you can control the side, starting position of the polygons, also you can define your own seeds, for example drawing curves or using the grammar of genr8.

this example represent a square:

Edge0 + ~ Edge1 + ~ Edge0 + Edge1
Edge0 -> Edge0 [ [ + Edge1 ] - ~ Edge1 ] Edge0
Edge1 -> Edge1 [ [ + Edge0 ] - ~ Edge0 ] Edge1
Angle 90

there are some conditionals to create grammar, In the first line you have to define the Axiom, and only can be a regular polygon, and may only contain ” + “, “~” and Edge(number). Each word should be separated by one space, and the lines need a return. and the comments have to be in separated lines and starting like C++ with two “//”, so there are more elements and rules to create seeds by grammar, but this is an idea how can they work.

To create my Own grammars I start using the predifined types and then looks how they work and so on…

After you define your grammar you have to define the different elements of the growth, for example:

n/ -> the number of the growth steps

s/ -> the sacale of each growth step

rn/ -> the noise that you want in the growth.

fc/ -> fix the center of the growth

ds/ -> if you want draw every step of the growth

and there are too much Mel commands to create and define the environment.

So the plugin has to control: the scaffold, the environment, the Grammar, the Genetic Engine and the Fitness.

The first exercises come from the page and the papers who explain genr8. the other ones are developed by me.

captura-pantalla.jpg

Default Examples:

genr8 -kc

genr8 -fp -sl 8 -n 5 -ba 70 -t 4 -r 0 0 3 -rn 0.1 -s 1.1

polyCube -w 3 -h 4 -d 3
genr8 -t 3 -rn 0.1 -n 4

polyCube -w 3 -h 4 -d 3
genr8 -t 3 -n 5 -a 0 0 4 -g z -0.5

PolySphere -r 5
genr8 -t 4 -n 5 -ba 90 -g z -1 -sp 0 0 7 -sl 3 -s 1.3

genr8 -t 4 -n 6 -ds -s 1.3 -r 0 0 -3 -r 0 4 0 -ba 90 -r 1 -3 -4 -r 2 2 5 -r -3 -2 1

genr8 -t 3 -n 5 -g z -1 -r 0 0 -3

polyCube -w 3 -h 4 -d 3
genr8 -t 4 -n 5 -r 3 3 3 -co

personal experiment:

genr8 -n 5 -rn 0.2 -t 4 -r 0 0 3
-intersting surface results

-Variation 1
genr8 -n 5 -rn 0.2 -t 4 -g z -1 -r 0 0 -3

-Variation 2
genr8 -n 8 -rn 0.1 -t 3 -g z -1 -r 0 0 3 -r 0 0 -3
polyCube -w 15 -h 15 -d 5
genr8 -n 5 -rn 0.2 -t 4 -s 1.2 -a 7.5 7.5 -1 -a -7.5 7.5 -1 -a 7.5 -7.5 -1 -a -7.5 -7.5 -1 -r 0 0 -1
-before to execute, create the polyCube and select it.

-Variation 1 the same thing, select the Polycube before
genr8 -n 4 -rn 0.2 -t 4 -s 1.2 -a 3 3 -1 -a -3 3 -1 -a 3 -3 -1 -a -3 -3 -1 -r 0 0 -1

-Variation 2
-Select the polyCube to get a crazy result in the box.
-or leave it to run free to produce some kind of flower.
genr8 -n 8 -rn 0.2 -t 4 -s 1.2 -a 2 3 -1 -a -2 3 -1 -a 2 -3 -1 -a -2 -3 -1 -r 0 0 0

-looks some familiar element
genr8 -n 8 -fp -t 4 -r 0 0 -5

salida1.jpg

salida2.jpg

salida3.jpg

salida4.jpg

salida5.jpg