Monday, May 08, 2006

Rh4_060507_GrowingAlgorythm

AA STUDENTS PAVILON (discovered in the BD of last week)
Design by a student of the AA Unit of Charles Walker & Martin Self (both ARUP AGU)

Here is my first test on growing algorythm...
Highly inspired but for sure yet much less sophisticated...
L-system, fractals are now very trendy...





Option Explicit
Sub tree()
' ------------------------------------------------------
' seed radius
Dim intCircleRadius: intCircleRadius = 20
' growing tesselation
Dim intSubDivide: intSubDivide = 3
' growing twist differentation
Dim dblAngle : dblAngle = 120
' ------------------------------------------------------
'Dim arrCircles() 'dynamic array
Dim strCircle1, strCircle2, strCircle3, strCircle4, strCircle5
Dim arrCircGen1, arrCircGen2, arrCircGen3, arrCircGen4, arrCircGen5
' ------------------------------------------------------
' addRootCircle
Dim arrPlane: arrPlane = Rhino.WorldXYPlane
Dim strCircle: strCircle = Rhino.AddCircle (arrPlane, intCircleRadius)
' ------------------------------------------------------
arrCircGen1 = Subdiv (strCircle,intSubDivide,dblAngle)
For Each strCircle1 In arrCircGen1

arrCircGen2 = Subdiv (strCircle1,intSubDivide,dblAngle)
For Each strCircle2 In arrCircGen2

arrCircGen3 = Subdiv (strCircle2,intSubDivide,dblAngle)
For Each strCircle3 In arrCircGen3

arrCircGen4 = Subdiv (strCircle3,intSubDivide,dblAngle)
For Each strCircle4 In arrCircGen4

'arrCircGen5 = Subdiv (strCircle4,intSubDivide,dblAngle)
'For Each strCircle5 In arrCircGen5

Subdiv strCircle4,intSubDivide,dblAngle
'to be changed each time less growth

'Next
Next
Next
Next
Next
' ------------------------------------------------------
End Sub
' ------------------------------------------------------
Function Subdiv(strCircle,intSubDivide,dblAngle)
' getCenter
Dim arrPtCenter: arrPtCenter = Rhino.CircleCenterPoint(strCircle)
' subdiv
Dim arrPts: arrPts = Rhino.DivideCurve (strCircle, intSubDivide)
Dim i
For i = 0 To UBound(arrPts)
Randomize
' addRadial
Dim strRadial : strRadial = Rhino.AddLine (arrPtCenter, arrPts(i))
' collectOriginalEndPt
ReDim Preserve arrEndPtCollect(UBound(arrPts))
arrEndPtCollect(i) = Rhino.CurveEndPoint(strRadial)
' setLength
' ------------------------------------------------------
Dim dblLengthExtend : dblLengthExtend = 1/3*Rhino.CurveLength(strRadial)
' ------------------------------------------------------
Rhino.ExtendCurveLength strRadial, 0, 1, dblLengthExtend
' setNewOrigine
Dim arrEndPt: arrEndPt = Rhino.CurveEndPoint(strRadial)
' setNewRadius
Dim dblLengthRad: dblLengthRad = Rhino.CurveLength(strRadial)
' ------------------------------------------------------
Dim dblCircleRadius: dblCircleRadius = dblLengthRad/2
' ------------------------------------------------------
' setNewPlane
Dim arrDirection: arrDirection = Array( arrEndPt(0), arrEndPt(1), arrEndPt(2)+1 )
Dim arrPlane: arrPlane = Rhino.PlaneFromPoints(arrEndPt, arrPtCenter, arrDirection)
Dim arrRotated: arrRotated = RotatePlane(arrPlane, dblAngle, arrPlane(1))
' addNewCircle
ReDim Preserve arrCircles(i)
arrCircles(i) = Rhino.AddCircle (arrRotated, dblCircleRadius)
Next
' addCurve
Dim strPerimeter: strPerimeter = Rhino.addCurve ( Array(arrEndPtCollect(0),arrPtCenter,_ arrEndPtCollect(1),arrPtCenter,_ arrEndPtCollect(2),arrPtCenter,_
arrEndPtCollect(0)) )
' createSurf
Rhino.AddPlanarSrf Array(strPerimeter)
' returnFunction
Subdiv = arrCircles
End Function

Wednesday, May 03, 2006

Rh3_060503_Exhibited at the Royal Academie, London

(n)Tower, the maggie of nested loop...
COLLABORATIVE WORK WITH VINCENT NOWAK & CLAUDIA CORCILIUS (cici)
From DIN to DIM is a series of experimentations looking at transitions between the German Standard of design to self-similar objects controled by declared variables...
Both code are using simples nested loops




---------RECURSION---------

In mathematics and computer science, RECURSION specifies (or constructs) a class of objects or methods (or an object from a certain class) by defining a few very simple base cases or methods (often just one), and then defining rules to break down complex cases into simpler cases.

RECURSIVELY DEFINED SETS

* Example: the natural numbers

The canonical example of a recursively defined set is given by the natural numbers:

0 is in N
if n is in N, then n + 1 is in N
The set of natural numbers is the smallest set satisfying the previous two properties.

* Example: The set of true reachable propositions

Another interesting example is the set of all true "reachable" propositions in an axiomatic system.

* if a proposition is an axiom, it is a true reachable proposition.
* if a proposition can be obtained from true reachable propositions by means of inference rules, it is a true reachable proposition.
* The set of true reachable propositions is the smallest set of reachable propositions satisfying these conditions.

This set is called 'true reachable propositions' because: in non-constructive approaches to the foundations of mathematics, the set of true propositions is larger than the set recursively constructed from the axioms and rules of inference.

(Note that determining whether a certain object is in a recursively defined set is not an algorithmic task.)

RECURSION IN COMPUTER SCIENCE

A common method of simplification is to divide a problem into subproblems of the same type. As a computer programming technique, this is called divide and conquer and is key to the design of many important algorithms, as well as being a fundamental part of dynamic programming.

Recursion in computer programming is exemplified when a function is defined in terms of itself. One example application of recursion is in parsers for programming languages. The great advantage of recursion is that an infinite set of possible sentences, designs or other data can be defined, parsed or produced by a finite computer program.

Recurrence relations are equations to define one or more sequences recursively. Some specific kinds of recurrence relation can be "solved" to obtain a non-recursive definition.




Sub Tower()
' declare variables
Dim i, j
Dim arrCrvBank() 'dynamic array
' ------------------------------------------------------
' set variables: "Fl" = Floor
Dim intFloorNumber: intFloorNumber = 30
Dim intFloorHeight: intFloorHeight = 4'random(1,5)'random(1,3)'4
Dim intFloorRadius: intFloorRadius = Sin(i*10)+10'2'random(1,3)'(i/2+1,i)'8
' ------------------------------------------------------
Dim intSubDivide: intSubDivide = (2*intFloorNumber) + 4
Dim intLevel: intLevel = 0
' ------------------------------------------------------

' //////////////////////////////////////////////////////
'' FOR EVERY FLOOR
' //////////////////////////////////////////////////////
For i = 0 To intFloorNumber
Randomize
' ------------------------------------------------------
'' DRAW A CIRCLE
' ------------------------------------------------------
' setCenter
Dim x: x = 0'random(-1,1)'(-i/2,i/2)'0
Dim y: y = 0'random(-1,1)'(-i/2,i/2)'0
Dim z: z = intLevel
Dim arrCenter: arrCenter = Array(x,y,z)
' addCircle
Dim strCircle: strCircle = Rhino.AddCircle (arrCenter, intFloorRadius)
' ------------------------------------------------------
'' ROTATE THE CIRCLE
' ------------------------------------------------------
' getCircleDomain
Dim arrDomain: arrDomain = Rhino.CurveDomain(strCircle)
' Rotation for Twist
Dim intTwisting: intTwisting = i'random(1,(intSubDivide/2))
Dim dblParameter: dblParameter = arrDomain(0) + (arrDomain(1)/intSubDivide)*intTwisting
' reSet cercleOrigine
Rhino.CurveSeam strCircle, dblParameter
' ------------------------------------------------------
'' DIVIDE THE CIRCLE
' ------------------------------------------------------
' addPts onCircle
Dim arrPts: arrPts = Rhino.DivideCurve (strCircle, intSubDivide)
' deleteCircle
Rhino.DeleteObject strCircle

' //////////////////////////////////////////////////////
'' FOR EVERY (TWO) PTS
' //////////////////////////////////////////////////////
For j = 2 To UBound(arrPts) Step 2
' ------------------------------------------------------
'' DRAW A RADIAL
' ------------------------------------------------------
' addRadial
Dim strRadial : strRadial = Rhino.AddLine (arrPts(0), arrPts(j))
' ------------------------------------------------------
'' SET RADIAL LENGHT RADIAL
' ------------------------------------------------------
' setLength
Dim dblLength : dblLength = Random(2,10)
' getDomain : arrDomainRad(1) = original radius endPt
Dim arrDomainRad : arrDomainRad = Rhino.CurveDomain(strRadial)
' startPt
'Dim dblParam : dblParam = arrDomainRad(1) + (arrDomainRad(1) / dblLength)
Dim dblParam : dblParam = arrDomainRad(1) - (arrDomainRad(1) / dblLength)
Dim arrPointStart : arrPointStart = Rhino.EvaluateCurve(strRadial, dblParam)
' endPt
'dblParam = arrDomainRad(1) + dblParam
dblParam = arrDomainRad(1) + (arrDomainRad(1) / dblLength)
Dim arrPointEnd : arrPointEnd = Rhino.EvaluateCurve(strRadial, dblParam)
' ------------------------------------------------------
' deleteRadial
Rhino.DeleteObject strRadial
' ------------------------------------------------------
' SET PROFIL TO LOFT
' ------------------------------------------------------
' set arrPtsProfil
Dim arrPtsProfils: arrPtsProfils = array( arrPointStart,arrPts(j-1),arrPointEnd,arrPts(j+1),arrPointStart )
' addCurve
ReDim Preserve arrCrv((UBound(arrPts)/2)-1)
arrCrv((j/2)-1) = Rhino.AddCurve ( arrPtsProfils )
' addPolyline
ReDim Preserve arrPolyLines((UBound(arrPts)/2)-1)
arrPolyLines((j/2)-1) = Rhino.addPolyline ( arrPtsProfils )
Next
' //////////////////////////////////////////////////////

' ------------------------------------------------------
' createFloors
Dim arrFloor : arrFloor = Rhino.AddPlanarSrf ( arrPolyLines )
Rhino.SurfaceIsocurveDensity arrFloor, -1
' ------------------------------------------------------
' collecteCurvesToLoft (byFloors)
ReDim Preserve arrCrvBank(i): arrCrvBank(i) = arrCrv
' ------------------------------------------------------
' FOR NEXT LOOP:
intSubDivide = intSubDivide-2
intLevel = intLevel + intFloorHeight
' ------------------------------------------------------
Next
' //////////////////////////////////////////////////////



' //////////////////////////////////////////////////////
' INCREMENTAL LOFT PROCESS
' //////////////////////////////////////////////////////
Dim arrPolyLoft(), arrPtsCurves()
Dim intMax: intMax = intFloorNumber
j = 0
Do Until intMax = 0
' ------------------------------------------------------
For i=0 To intMax
ReDim Preserve arrPolyLoft(i)
arrPolyLoft(i) = arrCrvBank(i)(j)
Next
' ------------------------------------------------------
Dim strLoft : strLoft = Rhino.AddLoftSrf (arrPolyLoft,,,2,1,40)
Rhino.SurfaceIsocurveDensity strLoft, -1
j=j+1
intMax = intMax-1
Loop
' //////////////////////////////////////////////////////
End Sub

Labels: