Tuesday, September 25, 2007

070925_(n)certainties

(n)certainties biotopes is the brief of the studio Francois Roche / R&Sie and Marc Fornes / theverymany are co-teaching this Fall 2007 at Columbia University:
(n)certainties is based on Robotics & bottom up protocol of growth...
http://ncertainties.wordpress.com/
(thx Francois for the kind inviation!)



Option Explicit
'Script written by Marc Fornes
'Script copyrighted by Marc Fornes / theverymany.net
'Script version 13 September 2007 16:05:03

Call Main()
Sub Main()

Dim i,j,k
Dim arrPt

Dim dblLow : dblLow = -5
Dim dblUp : dblUp = 10

Dim arrPts()
Dim n : n = 0


Call rhino.enableRedraw(False)
' ===========================
For i = 0 To 5
For j = 0 To 5
For k = 0 To 5

ReDim Preserve arrpts(n)
arrPts(n) = array(random(dblLow, dblUp),random(dblLow, dblUp),random(dblLow, k*dblUp))
Call rhino.AddPoint (arrPts(n))

If n >= 2 Then
Dim arrPtNearer : arrPtNearer = functNearestNeighbor(arrPts, n)
Dim strLine : strLine = rhino.addLine(arrPts(n), arrPtNearer)
Call Rhino.AddCone (arrPts(n), arrPtNearer, 0.2)
call rhino.addSphere (arrPts(n), 0.2)
End If

n = n + 1

Next
Next
Next
' ===========================
Call rhino.enableRedraw(True)


End Sub


Function random(low, up)
Randomize
random = (up - low) * Rnd + low
End Function

Function functNearestNeighbor (arrPts, index)

Dim k, dblDist
Dim dblDistMin : dblDistMin = 100000

For k = 0 To UBound(arrPts)

dblDist = Rhino.Distance(arrPts(index), arrPts(k))

If dblDist <> 0 And dblDist < dblDistMin Then
dblDistMin = dblDist
Dim arrPtNearest : arrPtNearest = arrPts(k)
End If

Next

functNearestNeighbor = arrPtNearest

End Function

Labels: , , ,