(n)certainties – Columbia – Fall 2008

MS-Robot Path Protocol, Robot affilations

Each initial point represents one robot. They group themselves in packs of three and build a vault to the trio’s common center point . Then, each Robot picks a random point on their own previous contribution, finds different affiliates, and builds again. This only represents an ideal meta-path. A secondary path, iterated by each robot along their meta-path, will apply the material. Further, moments of failure, vault abandonment, and  rogue robots will be Incorporated.

 

 

Option Explicit
‘Script written by <mathew staudt>
‘Script copyrighted by <no>
‘Script version Wednesday, October 01, 2008 1:47:11 PM

Call Main()
Sub Main()
 Dim ObjPoints, arrPoints(), i, q, arrTri()
 Dim k1, j1, n, s, NumTri, t, arrTri1(), y, b
 
 k1=0
 j1=0
 n=0
 
 ”Get Points
 ObjPoints = Rhino.GetObjects (“Select Your Shit Slinging Robots”, 1)
 For i=0 To Ubound(ObjPoints)
  ReDim Preserve arrPoints(i)
  arrPoints(i)= Rhino.PointCoordinates (ObjPoints(i))
 Next
 NumTri = i/3

 
 ”Organize Initial points into groups of three
 For q=0 To NumTri-1
  ReDim Preserve arrTri(q)
  arrTri(q) = FindTriangleStart(arrPoints, k1, j1, n)
  For s=0 To 2
   Rhino.AddSphere arrTri(q)(s), 5
  Next
  If q < NumTri-1 Then
   Call PurgeWinners (arrPoints, k1, j1, n)
   k1=0
   j1=0
   n=0
  End If
 Next
 
 ”Vault Initlal Groups of 3
 For t= 0 To Ubound (arrTri)
  ReDim Preserve arrTri1 (t)
  arrTri1(t) = Vault (arrTri(t))
  
 Next
 
 
 ”Loop: reset Point affilations, then Vault
 
 
 For y = 0 To 2
  
  Call FindTriangleCont (arrTri1) 
 
  
  For t= 0 To Ubound (arrTri1)
   ReDim Preserve arrTri (t)
   arrTri(t) = Vault (arrTri1(t))
  
   
  Next
  For t= 0 To Ubound (arrTri)
   ReDim Preserve arrTri1 (t)
   arrTri1(t) = arrTri(t)
  Next

  
 
  
 Next
 
 
      
 
End Sub

Function FindTriangleStart(arrpts, ByRef k1, ByRef j1, ByRef n)

 Dim i, objpts(), arrBBox, arrCntrPt, WinnerPt
 Dim DblDistTest, WinningDist, p, g, z
 Dim WinnTriLength, j, k, winTri
 Dim lineTestLength, d_A, d_B, d_C, d_Avg, Plus_Avg, Minus_Avg
 
 For i=0 To Ubound (arrpts)
  ReDim Preserve objpts(i)
  objpts(i) = Rhino.AddPoint (arrpts(i))
 Next
 
 
 ”Find Center Of Points
 
 arrBBox = Rhino.BoundingBox(objpts)
 arrCntrPt = array((((arrBBox(2)(0)) + (arrBBox(0)(0))) / 2), (((arrBBox(2)(1)) + (arrBBox(0)(1))) / 2), (((arrBBox(0)(2)) + (arrBBox(4)(2))) / 2))
 Rhino.addsphere arrCntrPt, 0.5
 For z=0 To Ubound(objpts)
  Rhino.DeleteObject (objpts(z))
 Next
 
 
 
 
 ”Find Point Furthest From Center
 
 For p=0 To Ubound(arrpts)
  DblDistTest = Rhino.Distance (arrCntrPt, arrpts(p))
  If DblDistTest > WinningDist Then
   WinningDist = DblDistTest
   WinnerPt = arrpts(p)
   n=p
  End If
 Next
 Rhino.addsphere WinnerPt, 0.5
 

 
 
 ”Find Smallest Triangel From Winning Point

 
 WinningDist = 500
 WinnTriLength = 500
 g=0
 
 For j=0 To Ubound (arrpts)
  If Rhino.PointCompare (WinnerPt, arrpts(j)) = False Then
   For k=j+1 To Ubound (arrpts)
    If Rhino.PointCompare (WinnerPt, arrpts(k)) = False Then
     d_A = Rhino.Distance(WinnerPt,arrpts(j))
     d_B = Rhino.Distance(WinnerPt,arrpts(k))
     d_C = Rhino.Distance(arrpts(j),arrpts(k))
     lineTestLength = d_A + d_B + d_C
     d_Avg = (d_A+d_B+d_C)/3
     Plus_Avg = d_Avg +2*d_Avg
     Minus_Avg = d_Avg -2*d_Avg
     If Plus_Avg > d_A > Minus_Avg And Plus_Avg > d_B > Minus_Avg And Plus_Avg > d_C > Minus_Avg Then
      g=g+1
      If g = 1 Then
       WinnTriLength = lineTestLength
       j1= j
       k1= k
       winTri= array(WinnerPt, arrpts(j), arrpts(k))
      Else
       If lineTestLength < WinnTriLength Then
        WinnTriLength = lineTestLength
        j1= j
        k1= k
        winTri= array(WinnerPt, arrpts(j), arrpts(k))
       End If
      End If
     End If
    End If
   Next
  End If
 Next

 
 FindTriangleStart = winTri
End Function
Function FindTriangleCont (ByRef arrTri)
 Dim f, u, j, k, f1, u1, j1, k1, p1, q1, ArrDblStart, winTri()
 Dim WinningDist, DblDistTest, WinnerPt, WinnTriLength
 Dim lineTestLength, d_A, d_B, d_C, d_Avg, Plus_Avg, Minus_Avg, a, g, i, w, b
 
 
 For a = 0 To Ubound(arrTri)
  g=0

 
  ArrDblStart = FindStart_4Tri (arrTri)
  p1 = ArrDblStart(0)
  q1 = ArrDblStart(1)
  WinnerPt = arrTri(p1)(q1)
 
  For f=0 To Ubound (arrTri)
   If f <> p1 Then
    For u=0 To 2
     If IsNull (arrTri(f)(u)) Then
     Else 
      For j=0 To Ubound (arrTri)
       If j<> p1 Then
        For k=0 To 2
         If IsNull (arrTri(j)(k)) Then
         Else 
          If Rhino.PointCompare (arrTri(f)(u), arrTri(j)(k)) = False Then
           d_A = Rhino.Distance(WinnerPt,arrTri(f)(u))
           d_B = Rhino.Distance(WinnerPt,arrTri(j)(k))
           d_C = Rhino.Distance(arrTri(f)(u),arrTri(j)(k))
           lineTestLength = d_A + d_B + d_C
           d_Avg = (d_A+d_B+d_C)/3
           Plus_Avg = d_Avg +2*d_Avg
           Minus_Avg = d_Avg -2*d_Avg
           If Plus_Avg > d_A > Minus_Avg And Plus_Avg > d_B > Minus_Avg And Plus_Avg > d_C > Minus_Avg Then
            g=g+1
            If g = 1 Then
             WinnTriLength = lineTestLength
             j1= j
             k1= k
             f1=f
             u1=u
             ReDim Preserve winTri(a)
             winTri(a) = array(WinnerPt, arrTri(f)(u), arrTri(j)(k))
            Else
             If lineTestLength < WinnTriLength Then
              WinnTriLength = lineTestLength
              j1= j
              k1= k
              f1=f
              u1=u
              ReDim Preserve winTri(a)
              winTri(a) = array(WinnerPt, arrTri(f)(u), arrTri(j)(k))
             End If
            End If
           End If
          End If
         End If
        Next
       End If
      Next
     End If
    Next
   End If
  Next
  arrTri(f1)(u1) = Null
  arrTri(j1)(k1) = Null
  arrTri(p1)(q1) = Null
 
 Next
 For w = 0 To Ubound (winTri)
  For b = 0 To 2
   arrTri(w)(b) = winTri(w)(b)
  Next
 Next
 
  
End Function

Function FindStart_4Tri (arrTri)

 Dim i, j, objpts(), arrBBox, arrCntrPt, z, p, q, p1, q1, n
 Dim DblDistTest,WinnerPt, WinningDist
 n=0
 
 For i=0 To Ubound (arrTri)
  For j=0 To 2
   If IsNull (arrTri(i)(j)) Then
   Else 
    ReDim Preserve objpts(n)
    objpts(n) = Rhino.AddPoint (arrTri(i)(j))
    n=n+1
   End If
  Next
 Next
 
 arrBBox = Rhino.BoundingBox(objpts)
 arrCntrPt = array((((arrBBox(2)(0)) + (arrBBox(0)(0))) / 2), (((arrBBox(2)(1)) + (arrBBox(0)(1))) / 2), (((arrBBox(0)(2)) + (arrBBox(4)(2))) / 2))
 Rhino.addsphere arrCntrPt, 0.5
 For z=0 To Ubound(objpts)
  Rhino.DeleteObject (objpts(z))
 Next
 
 For p=0 To Ubound (arrTri)
  For q=0 To 2
   If IsNull (arrTri(p)(q)) Then
   Else 
    DblDistTest = Rhino.Distance (arrCntrPt, arrTri(p)(q))
    If DblDistTest > WinningDist Then
     WinningDist = DblDistTest
     WinnerPt = arrTri(p)(q)
     p1 = p
     q1 = q
    End If
   End If
  Next
 Next
 

 

 FindStart_4Tri = Array (p1, q1)
End Function

 
Function PurgeWinners (ByRef arrpts, one, two, three)
 Dim i, n, Bank(), j
 
 n=0
 arrpts(one) = Null
 arrpts(two) = Null
 arrpts(three) = Null
 

 For i=0 To Ubound (arrpts)
  If IsNull (arrpts(i)) Then
  Else
   ReDim Preserve Bank(n)
   Bank(n)= arrpts(i)
   n=n+1
  End If
 Next
 
 For j=0 To Ubound(Bank)
  ReDim Preserve arrpts(j)
  arrpts(j) = Bank(j)
 Next
 
 
 
 
 
End Function
Function Vault (arrVpts)
 Dim arrBBox, arrCntrPt, ObjVpts()
 Dim arrCenZ, Arrd(2), d, r, i, j, arrVptsZ(), arrVcrv()
 Dim HFactor, arrHold()
 
 HFactor=1.5
 
 For i=0 To Ubound(arrVpts)
  ReDim Preserve ObjVpts(i)
  ObjVpts(i)= Rhino.AddPoint (arrVpts(i))
 Next
 
 Arrd(0) = Rhino.Distance(arrVpts(0),arrVpts(1))
 Arrd(1) = Rhino.Distance(arrVpts(1),arrVpts(2))
 Arrd(2) = Rhino.Distance(arrVpts(2),arrVpts(0))
  
 
 d= Rhino.Max (Arrd)
 r= d/2
 
 arrBBox = Rhino.BoundingBox(ObjVpts)
 arrCntrPt = array((((arrBBox(2)(0)) + (arrBBox(0)(0))) / 2), (((arrBBox(2)(1)) + (arrBBox(0)(1))) / 2), (((arrBBox(0)(2)) + (arrBBox(4)(2))) / 2))
 arrCenZ= Rhino.PointAdd(arrCntrPt, array(0,0,HFactor*r))
 
 
 For j = 0 To Ubound (arrVpts)
  ReDim Preserve arrVptsZ(j)
  ReDim Preserve arrVcrv(j)
  ReDim ObjVpts (2)
  ReDim Preserve arrHold(j)
  arrVptsZ(j)=Rhino.PointAdd(arrVpts(j), array(0,0,HFactor*r*0.9))
  arrVcrv(j)= Rhino.AddCurve (array(arrVpts(j),arrVptsZ(j), arrCenZ))
  ObjVpts(j) = Rhino.DivideCurveLength (arrVcrv(j), RdmPonC (arrVcrv(j)))
  arrHold(j) = ObjVpts(j)(1)
  
 Next
 Vault = arrHold
End Function
Function RdmPonC(ObjCrv)
 Dim nMax, nMin
 
 nMax= .9*Rhino.CurveLength(ObjCrv)
 nMin= 0.1*nMax
 
 
 RdmPonC = Null
 If Not IsNumeric(nMin) Then Exit Function
 If Not IsNumeric(nMax) Then Exit Function
 If nMin >= nMax Then Exit Function
 Randomize
 RdmPonC = Int((nMax – nMin + 1) * Rnd + nMin)
End Function

Leave a Comment

0 responses so far ↓

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

Leave a Comment