(n)certainties – Columbia – Fall 2008

Stay in the box (in process)

October 8, 2008 · Leave a Comment

Call Main()
Sub Main()

Dim strSrf : strSrf = Rhino.GetObject(“closed surface”,16)

Dim arrPtSeed : arrPtSeed = Rhino.GetObject(“Base Point”,1)
arrPtSeed = Rhino.PointCoordinates(arrPtSeed)

Dim n : n = 200 ‘Rhino.GetInteger(“nr of points”, 10)

” SPEED:
Dim bbox : bbox = Rhino.BoundingBox(strSrf)
Dim min : min = -50 ‘Rhino.Distance(bbox(0),bbox(6))/8
Dim max : max = 50′ Rhino.Distance(bbox(0),bbox(6))/4

Dim i, k : k = 1 : i = 0
Dim arrPt
Dim arrPtsCollect()

ReDim Preserve arrPtsCollect(0)
arrPtsCollect(0) = arrPtSeed

‘For i=0 To n-1
Do Until k = n+1

arrPt = array(arrPtSeed(0)+arbitraryValue(min, max),_
arrPtSeed(1) + arbitraryValue(min, max),_
arrPtSeed(2)+ arbitraryValue(min, max))

If Rhino.IsPointInSurface (strSrf, arrPt) then
ReDim Preserve arrPtsCollect(k)
arrPtsCollect(k) = arrPt
Call rhino.AddLine(arrPtsCollect(k-1), arrPtsCollect(k))
k = k + 1
i = 0
Else
i = i + 1
End If

If i = 100 Then Exit Sub

Loop
‘Next
Call rhino.AddPolyline(arrPtsCollect)

End Sub

Function arbitraryValue(min, max)
Randomize
arbitraryValue = Int((max – min + 1) * Rnd + min)
End Function

Stay_in_box

Stay_in_box

Categories: Adolfo Nadal

0 responses so far ↓

  • There are no comments yet...Kick things off by filling out the form below.

Leave a Comment