(n)certainties – Die Angewandte – Fall 2008

17X_Atr/Rep

atrrep2atrrep013atrrep031atrrep044

 

 

 

 

 

 

 

 

 

 

Option Explicit
‘Script written by <insert name>
‘Script copyrighted by <insert company name>
‘Script version 11 listopada 2008 12:07:51

Call Main()
Sub Main()
 Dim aPts(),strB
 Dim i
 Dim aPtTemp
 Dim aPtsNeighbors
 Dim nMin : nMin = -2
 Dim nMax: nMax =2
 Dim dblSearchRad: dblSearchRad =1
 Dim aA
 
 ReDim Preserve aPts(0)
 
 aPts(0) = rhino.GetPoint(“pick seed”)
 aA = rhino.GetPoint(“get Attractor”)
 strB = rhino.getobject(“border”,8+16+32)
 
 For i=1 To 20
  
  Do
   aPtTemp = array(aPts(i-1)(0)+ eitherOr(nMin,nMax),_                     
    aPts(i-1)(1)+eitherOr(nMin,nMax),_                                                  
    aPts(0)(2))
 
   ” check its status
   If i > 1 Then
    aPtsNeighbors = searchWithinRad(aPtTemp, aPts, dblSearchRad)
    If Not isnull (aPtsNeighbors) Then
     Dim z : z = heighestZ(aPtsNeighbors)
     aPtTemp = array(aPts(i-1)(0)+ eitherOr(nMin,nMax),_
      aPts(i-1)(1)+eitherOr(nMin, nMax),_
      z+0.5)
    End If
   

   End If
  
   ” collect
   ReDim Preserve aPts(i)
   aPts(i) = aPtTemp
  
   ” Attraction,Probability
   DispAtr aA,i,aPts,aPtTemp,dblSearchRad,52
   
   ” Robot Steps
   RobotFoot i,aPts,aPtTemp,aA
  
   If  Not rhino.IsPointInSurface(strB,aPts(i))= True Then Exit Do
  
  Loop
  
  ” vizu
  ’Dim scircle : sCircle = rhino.AddCircle(rhino.MovePlane(Rhino.WorldXYPlane,aPts(i)),dblSearchRad)
  ’Call rhino.AddPlanarSrf(array(scircle))
  ’rhino.AddSphere aPts(i),dblSearchRad*RN(1,3)
 
 Next
 Dim strTrack
 ’Call rhino.addpolyline(aPts)
 ’strTrack = rhino.addinterpcurve(aPts)
End Sub
Function RN(nMin, nMax)
 Randomize
 RN = (nMax – nMin) * Rnd + nMin
End Function
Function eitherOr(n1, n2)
 Randomize
 If rnd > 0.5 Then
  eitherOr = n1
 Else
  eitherOr = n2
 End If
End Function
Function searchWithinRad(aPtSeed, aPts, dblRad)
 Dim i, dblDist, n
 Dim aPtscollect()
 For i = 0 To UBound(aPts)
  ’dblDist = rhino.Distance(aPtSeed, aPts(i))
  dblDist = rhino.Distance(aPtSeed, array(aPts(i)(0),aPts(i)(1),aPtSeed(2)))
  If dblDist < dblRad Then
   ReDim Preserve aPtscollect(n)
   aPtscollect(n) = aPts(i)
   ’Call rhino.addPoint(aPtscollect(n))
   n = n + 1
  End If
 Next
 If n = 0 Then
  searchWithinRad = Null
 Else
  searchWithinRad = aPtscollect
 End If
End Function
Function heighestZ(aPts)
 Dim i
 Dim z : z = 0
 For i = 0 To Ubound(aPts)
  If aPts(i)(2) > z Then z = aPts(i)(2)
 Next
 heighestZ = z
End Function
Function DispAtr(aA,i,aPts,aPtTemp,dblSearchRad,dblChance)
 Dim la ,lb, lc, ld
 Dim arrla, arrlb, alfa, R
 Dim cTL, cPL
 Dim CrossSectionPlane
 Dim aPtsNeighbors
 ’do 
 la=Rhino.addline(aPts(i-1),aA)
 lb = rhino.AddLine(aPts(i-1),Rhino.EvaluateCurve (la, rhino.distance(aPts(i-1),aPtTemp)))
 R=rhino.distance(aPts(i-1),aPtTemp)
 
 cPL = Array(0,1,0)
 cTL = Rhino.CurveTangent(la,0)
  
 CrossSectionPlane = Rhino.PlaneFromFrame(aPts(i-1),cTL ,cPL)
 ’Rhino.ViewCPlane, Rhino.PlaneFromFrame(aPts(i-1), cTL, cPL)
  
 lc=rhino.RotateObject (lb,aPts(i-1),eitherOr(-1,1)*RN(0,dblChance)*R,,True)   
 aPts(i) = rhino.curveendpoint(lc)

 If i > 1 Then
  aPtsNeighbors = searchWithinRad(aPtTemp, aPts, dblSearchRad)
  If Not isnull (aPtsNeighbors) Then
   Dim z : z = heighestZ(aPtsNeighbors)
  End If
  aPts(i) = array(rhino.curveendpoint(lc)(0),rhino.curveendpoint(lc)(1),z+0.5)
 End If  
 
  
 rhino.Objectlayer la,”la”
 rhino.Objectlayer lb,”lb”
 rhino.Objectlayer lc,”lc”

 ’If  rhino.IsPointInSurface(strB,aPts(i))= True Then Exit Do  
 ’Loop
 
End Function

Leave a Comment

0 responses so far ↓

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

You must be logged in to post a comment.