(n)certainties – Columbia – Fall 2007

071121_Agritect_v5.12

‘########################################################################################################
‘###     AGRITECT version 5.12 : November 21, 2007                                                      ###
‘###     Copyrighted Matthew R. Pauly, 2007, All rights reserved                                      ###
‘###     Script developed for (n)certainties studio                                                   ###
‘########################################################################################################
  Option Explicit
  Call Rhino.Print( ” __________________________ START OF SCRIPT ___________________________ ” )
  Dim gYEAR, gRINGS, gPLOT_low, gPLOT_high, gPath_height, gPath_divisions, gDirection, gPath_r1, gPath_r2
  Dim gCheck, gPLOT_struct, lPi
  lPi = Rhino.Pi()
‘######################################## GLOBAL PARAMETERS #############################################
 gYEAR = 400            ’<— Global YEARS the system runs
 gPLOT_high = 200      ’<— Yield, High (in bushels per acre)
 gPLOT_low = 160      ’<— Yield, Low  (in bushels per acre)
 gPath_height = 10         ’<— Start floor to floor height (in meters)
 gPath_r1 = 80      ’<— TEMPORARY seed inner radius(start)
 gPath_r2 = 24     ’<— TEMPORARY seed thickness
 gDirection = 1     ’<— TEMPROARY might change direction depending on seed, Not used
 gPath_divisions = 25   ’<— Number of “chutes” and seeds
 gCheck = gPath_r2 * 3  ’<— Distance to Leech
 gPLOT_struct = (lPi/gPath_divisions)/10′<— Structure Width (in rads)
 ’——FIXED VARIABLES——
 gRINGS = 7       ’<— Number of rings  (3 PLOT, 4 INTERSTICE)
‘########################################################################################################
Call Rhino.EnableRedraw(false)
Call Growth(gYEAR, gRINGS, gPLOT_high, gPLOT_low, gPath_r1, gPath_r2,gPLOT_struct)
Call Rhino.EnableRedraw(true)
‘________________________________________________________________________________________________________
Sub Growth(gYEAR, gRINGS, gPLOT_high, gPLOT_low, gPath_r1, gPath_r2,gPLOT_struct)
 Dim i, temp, lYEAR, gSEED, lSEED, lTheta, lPi, tTheta
 Dim tArr_1(), tArr_1b(), tArr_1c(), tArr_1d(), tArr_2(), tArr_2b(), tArr_2c(), tArr_2d(), tArr_3(2)
 Dim tYield_1(), tYield_2(), gSEED_start(1), tArr_4(1)
 Dim gPLOT(), gPLOT2(), gPLOT3(), gPLOT4()
 Dim gPLOT_lYield(), gPLOT_gYield(), gSEED_chute, gSEED_check(), gSEED_surplus()
 Dim gROBOT_max1, gROBOT_max2, gROBOT_min1, gROBOT_min2
 lTheta = 0
 lPi = Rhino.Pi()
‘———————————————- LOCAL VARIABLES —————————————–
 gSEED = 0′gPath_divisions     ‘<— TEMPORARY Number of seeds, should be lost offspring limit
 gROBOT_max1 = gPath_r1 * 1.01 ’<— Maximum Radius from inner factory
 gROBOT_max2 = gPath_r2 * 2.5     ’<— Maximum width the Robot can expand to
 gROBOT_min1 = gPath_r1 *.99    ‘<— Minimum Radius from inner factory
 gROBOT_min2 = gPath_r2    ’<— Minimum Width of Robot
‘——————————————————————————————————–
 For lYEAR = 0 to gYEAR
  Redim Preserve gPLOT(lYEAR), gPLOT2(lYEAR), gPLOT3(lYEAR), gPLOT4(lYEAR), gPLOT_lYield(lYEAR), gPLOT_gYield(lYEAR)

  Call func_gYIELD(gPLOT_gYield, gPLOT_low, gPLOT_high, lYEAR)
  If lYEAR < (gPATH_divisions + 1) Then
  lTheta = ((2*lPi)/gPath_divisions ) + lTheta  
  End If
  tTheta = lTheta
  ’———————————————————————————————— 
  For lSEED = 0 to gSEED
   Redim Preserve tArr_1(lSEED), tArr_1b(lSEED), tArr_1c(lSEED), tArr_1d(lSEED), tYield_1(lSEED)
   If lYEAR = 0 Then
    gSEED_chute = 0
    Redim Preserve gSEED_check(lSEED), gSEED_surplus(lSEED)
    gSEED_check(lSEED) = 0
    gSEED_surplus(lSEED) = 0
   End If
   gSEED_check(0) = gPath_divisions + 1
   ’—— Establish each seed’s starting point —–
   If lYEAR < gPath_divisions Then
    If lSEED = 0 Then
     gSEED_start(0) = 0
     gSEED_start(1) = 0
    Else
     gSEED_start(0) = Cos( ((2*lPi)/gPath_divisions)*lSEED )*(  (gPath_r1 + gPath_r2)*2.3 )
     gSEED_start(1) = Sin( ((2*lPi)/gPath_divisions)*lSEED )*(  (gPath_r1 + gPath_r2)*2.3 )
    End If
   Else
    tArr_4(0)=0 
    tArr_4(1)=0 
    For i = 1  to gPath_divisions
     tARR_4(0) = tARR_4(0) + gPLOT(lYEAR-i)(lSEED)(0)(0)
     tARR_4(1) = tARR_4(1) + gPLOT(lYEAR-i)(lSEED)(0)(1)
    Next
    gSEED_start(0) = tARR_4(0)/gPath_divisions
    gSEED_start(1) = tARR_4(1)/gPath_divisions

   End If
   ’————————————————–
   If gSEED_check(lSEED) = 0 And gSEED_chute = lSEED And gPLOT_gYield(lYEAR) > ((gPLOT_high+gPLOT_low)/2) Then
    gSEED_surplus(lSEED) = gSEED_surplus(lSEED) + gPLOT_gYield(lYEAR) – ((gPLOT_high+gPLOT_low)/2)
    If gSEED_surplus(lSEED) > 40 Then ‘<— Critical Mass!!!!
     gSEED_check(lSEED) = 1
    End If
   End If  
   ’__________________________________________________________________________________________  
   Dim temp_Distance3, tHeight
   temp_Distance3 = 0
   
   For i = 0 to gRINGS
    Redim Preserve tArr_2(i), tArr_2b(i),  tArr_2c(i), tArr_2d(i), tYield_2(i)
    tArr_2(i) = tArr_3  
    tArr_2b(i) = tArr_3
    tArr_2c(i) = tArr_3
    tArr_2d(i) = tArr_3  
    Call func_YIELD(tYield_2, gPLOT_gYield, lYEAR, i)  ’<— Assign local Yield 
   ’—— POSITION ASSIGNMENT ——
   If gSEED_check(lSEED) = 0 Then
    tArr_2(i) = array(gSEED_start(0), gSEED_start(1), 0)  ‘<—- Point assignment for non-triggered seeds
      Else
   ’———————————
    Dim temp_Distance1, temp_Distance2, lPath_r1, lPath_r2
     If lYEAR > gPath_divisions And gSEED_check(lSEED) > gPath_divisions Then ‘ALL LEVELS ABOVE FIRST

     temp_Distance1 = Rhino.Distance(gPLOT(lYEAR – gPATH_divisions)(lSEED)(gRings), gPLOT(lYEAR – gPATH_divisions)(lSEED)(0))
     temp_Distance2 = Rhino.Distance(array( gSEED_start(0), gSEED_start(1), gPLOT(lYEAR – gPATH_divisions)(lSEED)(gRINGS)(2) ), gPLOT(lYEAR – gPATH_divisions)(lSEED)(gRINGS))
     lPath_r2 =  temp_Distance1  * ( (gPLOT_gYield(lYEAR)-gPLOT_low/1.15)/((gPLOT_high + gPLOT_low)/2-gPLOT_low/1.15) )
     lPath_r1 =  temp_Distance2  * ( (gPLOT_gYield(lYEAR))/((gPLOT_high + gPLOT_low)/2) )

     ’—- LIMIT: Robot Radii —
     If lPath_r2 > gROBOT_max2 Then lPath_r2 = gROBOT_max2 End If
     If lPath_r1 > gROBOT_max1 Then lPath_r1 = gROBOT_max1 End If
     If lPath_r2 < gROBOT_min2 Then lPath_r2 = gROBOT_min2 End If
     If lPath_r1 < gROBOT_min1 Then lPath_r1 = gROBOT_min1 End If     
     ’—- Z Location —-
     tArr_2(i)(2) = gPath_height * ((gPLOT_gYield(lYEAR)-gPLOT_low/1.15)/(((gPLOT_high+gPLOT_low)/2)-gPLOT_low/1.15))  + gPLOT(lYEAR-gPath_divisions)(lSEED)(i)(2)
      tArr_2b(i)(2) = tArr_2(i)(2)
      tArr_2c(i)(2) = tArr_2(i)(2)
      tArr_2d(i)(2) = tArr_2(i)(2)      

     If i = gRINGS Then
      Dim k
      tArr_2(i)(2) = gPath_height * ((gPLOT_gYield(lYEAR-1)-gPLOT_low/1.15)/(((gPLOT_high+gPLOT_low)/2)-gPLOT_low/1.15))  + gPLOT(lYEAR-gPath_divisions)(lSEED)(i)(2)      
      tHeight = tArr_2(i)(2)-tArr_2(0)(2)
      For k = 2 to gRings – 1 Step 2
       tArr_2(k)(2) =  tArr_2(0)(2) – tHeight*k/gRings 
       tArr_2(k-1)(2) = tArr_2(k)(2)
       tArr_2b(k)(2) = tArr_2(k)(2)
       tArr_2b(k-1)(2) = tArr_2b(k)(2) 
       tArr_2c(k)(2) = tArr_2(k)(2)
       tArr_2c(k-1)(2) = tArr_2b(k)(2) 
       tArr_2d(k)(2) = tArr_2(k)(2)
       tArr_2d(k-1)(2) = tArr_2b(k)(2)                         
      Next
     End If           
     ’—- XY Location —-
    If i = 0 Then ‘ Outer Point
     lTheta = (  ((2*lPi)/gPath_divisions )  ) + tTheta 
     ’lTheta = (  ((2*lPi)/gPath_divisions )*(tYield_2(i)/((gPLOT_high+gPLOT_low)/2))  ) + tTheta 
     tArr_2(i)(0) = (Cos(lTheta) *  lPath_r2)+ (Cos(lTheta) * lPath_r1) + gSEED_start(0)
     tArr_2(i)(1) = (Sin(lTheta) *  lPath_r2)+ (Sin(lTheta) * lPath_r1)+ gSEED_start(1)
     tArr_2b(i)(0) = (Cos(lTheta+gPLOT_struct) *  lPath_r2)+ (Cos(lTheta+gPLOT_struct) * lPath_r1) + gSEED_start(0)
     tArr_2b(i)(1) = (Sin(lTheta+gPLOT_struct) *  lPath_r2)+ (Sin(lTheta+gPLOT_struct) * lPath_r1)+ gSEED_start(1)     
     tArr_2c(i)(0) = (Cos(lTheta+2*gPLOT_struct) *  lPath_r2)+ (Cos(lTheta+2*gPLOT_struct) * lPath_r1) + gSEED_start(0)
     tArr_2c(i)(1) = (Sin(lTheta+2*gPLOT_struct) *  lPath_r2)+ (Sin(lTheta+2*gPLOT_struct) * lPath_r1)+ gSEED_start(1)
     tArr_2d(i)(0) = (Cos(lTheta+3*gPLOT_struct) *  lPath_r2)+ (Cos(lTheta+3*gPLOT_struct) * lPath_r1) + gSEED_start(0)
     tArr_2d(i)(1) = (Sin(lTheta+3*gPLOT_struct) *  lPath_r2)+ (Sin(lTheta+3*gPLOT_struct) * lPath_r1)+ gSEED_start(1)

     ’Call func_NEAR(gPLOT, tArr_2, lSEED, lYEAR, gCHECK, gPath_height) ‘<——-
    Else
     lTheta = (  ((2*lPi)/gPath_divisions )  ) + tTheta 
     ’lTheta = (  ((2*lPi)/gPath_divisions )*(tYield_2(i)/((gPLOT_high+gPLOT_low)/2))  ) + tTheta 
     If i = 1 Or i = 3 Or i = 5 Or i = 7 Then
      temp_Distance3 = temp_Distance3 + ((lPath_r2 – gPath_r2)/4)
     Else
      temp_Distance3 = temp_Distance3 + (gPath_r2/3)  
     End If
     tArr_2(i)(0) = (Cos(lTheta) *  (lPath_r2- temp_Distance3))+ (Cos(lTheta) * lPath_r1) + gSEED_start(0)
     tArr_2(i)(1) = (Sin(lTheta) *  (lPath_r2- temp_Distance3))+ (Sin(lTheta) * lPath_r1) + gSEED_start(1)
     tArr_2b(i)(0) = (Cos(lTheta+gPLOT_struct) *  (lPath_r2- temp_Distance3))+ (Cos(lTheta+gPLOT_struct) * lPath_r1) + gSEED_start(0)
     tArr_2b(i)(1) = (Sin(lTheta+gPLOT_struct) *  (lPath_r2- temp_Distance3))+ (Sin(lTheta+gPLOT_struct) * lPath_r1) + gSEED_start(1)
     tArr_2c(i)(0) = (Cos(lTheta+2*gPLOT_struct) *  (lPath_r2- temp_Distance3))+ (Cos(lTheta+2*gPLOT_struct) * lPath_r1) + gSEED_start(0)
     tArr_2c(i)(1) = (Sin(lTheta+2*gPLOT_struct) *  (lPath_r2- temp_Distance3))+ (Sin(lTheta+2*gPLOT_struct) * lPath_r1) + gSEED_start(1)
     tArr_2d(i)(0) = (Cos(lTheta+3*gPLOT_struct) *  (lPath_r2- temp_Distance3))+ (Cos(lTheta+3*gPLOT_struct) * lPath_r1) + gSEED_start(0)
     tArr_2d(i)(1) = (Sin(lTheta+3*gPLOT_struct) *  (lPath_r2- temp_Distance3))+ (Sin(lTheta+3*gPLOT_struct) * lPath_r1) + gSEED_start(1)
    End If
     ‘——————————-   
     Else ‘ FIRST LEVEL
       ’—- Z Location —-
       If lYEAR = 0  Or gSEED_check(lSEED) = 1 Then ‘FIRST YEAR
      tArr_2(i)(2)=0
      tArr_2b(i)(2)=0 
      tArr_2c(i)(2)=0
      tArr_2d(i)(2)=0
         Else
      tArr_2(i)(2)=(gPath_height/gPath_divisions) + gPLOT(lYEAR-1)(lSEED)(i)(2)
      tArr_2b(i)(2)=(gPath_height/gPath_divisions) + gPLOT(lYEAR-1)(lSEED)(i)(2)
      tArr_2c(i)(2)=(gPath_height/gPath_divisions) + gPLOT(lYEAR-1)(lSEED)(i)(2)
      tArr_2d(i)(2)=(gPath_height/gPath_divisions) + gPLOT(lYEAR-1)(lSEED)(i)(2)                  
     End If
     ’—- XY Location —-
     If i = 1 Or i = 3 Or i = 5 Or i = 7 Then
      tArr_2(i)(0) = tArr_2(i-1)(0)
      tArr_2(i)(1) = tArr_2(i-1)(1)
      tArr_2b(i)(0) = tArr_2b(i-1)(0)
      tArr_2b(i)(1) = tArr_2b(i-1)(1)  
      tArr_2c(i)(0) = tArr_2c(i-1)(0)
      tArr_2c(i)(1) = tArr_2c(i-1)(1)  
      tArr_2d(i)(0) = tArr_2d(i-1)(0)
      tArr_2d(i)(1) = tArr_2d(i-1)(1)                  
     Else
      tArr_2(i)(0) = ((Cos(lTheta) * ((gRings -i) /gRings) * gPath_r2)) + (Cos(lTheta) * gPath_r1) + gSEED_start(0)
      tArr_2(i)(1) = ((Sin(lTheta) * ((gRings -i) /gRings) * gPath_r2)) + (Sin(lTheta) * gPath_r1) + gSEED_start(1)
      tArr_2b(i)(0) = ((Cos(lTheta+gPLOT_struct) * ((gRings -i) /gRings) * gPath_r2)) + (Cos(lTheta+gPLOT_struct) * gPath_r1) + gSEED_start(0)
      tArr_2b(i)(1) = ((Sin(lTheta+gPLOT_struct) * ((gRings -i) /gRings) * gPath_r2)) + (Sin(lTheta+gPLOT_struct) * gPath_r1) + gSEED_start(1)
      tArr_2c(i)(0) = ((Cos(lTheta+2*gPLOT_struct) * ((gRings -i) /gRings) * gPath_r2)) + (Cos(lTheta+2*gPLOT_struct) * gPath_r1) + gSEED_start(0)
      tArr_2c(i)(1) = ((Sin(lTheta+2*gPLOT_struct) * ((gRings -i) /gRings) * gPath_r2)) + (Sin(lTheta+2*gPLOT_struct) * gPath_r1) + gSEED_start(1)
      tArr_2d(i)(0) = ((Cos(lTheta+3*gPLOT_struct) * ((gRings -i) /gRings) * gPath_r2)) + (Cos(lTheta+3*gPLOT_struct) * gPath_r1) + gSEED_start(0)
      tArr_2d(i)(1) = ((Sin(lTheta+3*gPLOT_struct) * ((gRings -i) /gRings) * gPath_r2)) + (Sin(lTheta+3*gPLOT_struct) * gPath_r1) + gSEED_start(1)            
     End If
     End If
   End If
    tArr_1(lSEED) = tArr_2     ’<— Assign “Ring Array” to Seed
    tArr_1b(lSEED) = tArr_2b
    tArr_1c(lSEED) = tArr_2c  
    tArr_1d(lSEED) = tArr_2d  
    tYield_1(lSEED) = tYield_2
   Next
   ’____________________________________________________________________________________________
    If  gSEED_check(lSEED) > 0 Then
     gSEED_check(lSEED) = gSEED_check(lSEED) + 1
    End If
   gPLOT_lYield(lYEAR) = tYield_1   
   gPLOT(lYEAR) = tArr_1
   gPLOT2(lYEAR) = tArr_1b
   gPLOT3(lYEAR) = tArr_1c
   gPLOT4(lYEAR) = tArr_1d          ’<— Assign “Seed Array” to Year 
  Next
  ’————————————————————————————————
    ’—- Adjust to next Chute —-
    If gSEED_chute < gPath_divisions Then
     gSEED_chute = gSEED_chute + 1
    Else
     gSEED_chute = 0
    End If
 Next
‘——————————————————————————————————–
‘Call func_BUILD1(gPLOT)
‘Call func_BUILD2(gPLOT, gPLOT2, gRINGS, gPath_divisions, gYEAR, gSEED)
Call func_BUILD3(gPLOT, gPLOT2, gPLOT3, gPLOT4, gRINGS, gPath_divisions, gYEAR)

End Sub
‘________________________________________ FUNCTION : BUILD 1  ____________________________________________
Function func_BUILD1(gPLOT)
Dim lYEAR, lSEED, i
 For lYEAR = 1 to uBound(gPLOT)
  For lSEED = 0 to uBound(gPLOT(lYEAR))
 ’Call Rhino.EnableRedraw(false)’<—–
   For i = 1 to (uBound(gPLOT(lYEAR)(lSEED))-1)
    If gPLOT(lYEAR)(lSEED)(i)(0) <> 0 And gPLOT(lYEAR)(lSEED)(i)(1) <> 0 And gPLOT(lYEAR)(lSEED)(i)(2) <> 0  Then
    If i = 2 Or i = 4 or i = 6 Then
     ’Call Rhino.AddSrfPt (array(gPLOT(lYEAR)(lSEED)(i),gPLOT(lYEAR)(lSEED)(i-1),gPLOT(lYEAR-1)(lSEED)(i-1),gPLOT(lYEAR-1)(lSEED)(i)) )
    End If
    End If
    If lYEAR > gPath_Divisions Then
     ’Call Rhino.AddLine(gPLOT(lYEAR)(lSEED)(i),  gPLOT(lYEAR-gPATH_divisions)(lSEED)(i))
     ’Call Rhino.AddSrfPt (array(gPLOT(lYEAR)(lSEED)(i),gPLOT(lYEAR-1)(lSEED)(i),gPLOT(lYEAR-gPath_divisions-1)(lSEED)(i),gPLOT(lYEAR-gPATH_divisions)(lSEED)(i)) )
    End If
   Next
   If lYEAR > gPATH_divisions And gPLOT(lYEAR)(lSEED)(0)(0) <> 0 And gPLOT(lYEAR)(lSEED)(0)(1) <> 0 And gPLOT(lYEAR)(lSEED)(0)(2) <> 0  Then
   If lYEAR > gPATH_divisions And gPLOT(lYEAR-gPATH_divisions)(lSEED)(0)(0) <> 0 And gPLOT(lYEAR-gPATH_divisions)(lSEED)(0)(1) <> 0 And gPLOT(lYEAR-gPATH_divisions)(lSEED)(0)(2) <> 0  Then

     Call Rhino.AddCylinder(gPLOT(lYEAR)(lSEED)(0), gPLOT(lYEAR-gPATH_divisions)(lSEED)(0), .6)
     Call Rhino.AddCylinder(gPLOT(lYEAR)(lSEED)(0), gPLOT(lYEAR)(lSEED)(1), .6)     
     Call Rhino.AddCylinder(gPLOT(lYEAR)(lSEED)(gRINGS), gPLOT(lYEAR-gPATH_divisions)(lSEED)(gRINGS), .6)
     Call Rhino.AddCylinder(gPLOT(lYEAR)(lSEED)(gRINGS), gPLOT(lYEAR)(lSEED)(gRINGS-1), .6)
     Call Rhino.AddCylinder(gPLOT(lYEAR)(lSEED)(2), gPLOT(lYEAR)(lSEED)(3), .6)
     Call Rhino.AddCylinder(gPLOT(lYEAR)(lSEED)(4), gPLOT(lYEAR)(lSEED)(5), .6) 
    
   End If
   End If

  Next
 ’Call Rhino.EnableRedraw(true) ‘<—–
 Next
End Function
‘________________________________________ FUNCTION : BUILD 2  ____________________________________________
Function func_BUILD2(gPLOT,gPLOT2, gRINGS, gPath_divisions, gYEAR, gSEED)
Dim lYEAR, lSEED, i, n, tARRAY(), tARRAY2(),tCIRCLES, tPline, j, k, m, p, tStep
Dim arrPlane, sLofter(), sLofter2()
arrPlane = Rhino.WorldXYPlane
‘———————– Rings ————————
For lSEED = 0 to gSEED
Redim sLofter(0), sLofter2(0)
For m = 1 to 3
 p = 0
 For n = 0 to gPATH_divisions
  j = 0
  If p = 0 Then
   tStep = gPath_divisions
   Else
   tStep = 0
  End If

  For i = 0 to (gYEAR-tStep) Step gPATH_divisions
   If i+n <= gYEAR Then
    If gPLOT(i+n)(lSEED)(m*2-1)(2) <> 0 Then
     Redim Preserve tARRAY(j), tARRAY2(j)
     tARRAY(j) = gPLOT(i+n)(lSEED)(m*2-1)
     tARRAY2(j) = gPLOT2(i+n)(lSEED)(m*2-1)
     j = j + 1
    End if
   End If
   k = i
  Next
  For i = k to 0 Step -gPATH_divisions
   If i+n <= gYEAR Then
    If gPLOT(i+n)(lSEED)(m*2)(2) <> 0 Then
     Redim Preserve tARRAY(j), tARRAY2(j)
     tARRAY(j) = gPLOT(i+n)(lSEED)(m*2)
     tARRAY2(j) = gPLOT2(i+n)(lSEED)(m*2)
     j = j + 1
    End If
   End If
  Next
  Redim Preserve tARRAY(j), tARRAY2(j)
  tARRAY(j) = tARRAY(0)
  tARRAY2(j) = tARRAY2(0)
 
  Redim Preserve sLofter(p)
  sLofter(p) = Rhino.AddPolyline (tARRAY)
  p = p+1  
  Redim Preserve sLofter(p)
  sLofter(p) = Rhino.AddPolyline (tARRAY2)  
  p = p+1
 Next
 Call Rhino.AddLoftSrf(sLofter) 
Next
Next
lSEED = 0
Dim tARRAY_2
For m = 0 to gYEAR
 For n = 0 to 2
  If m > (gPath_divisions * 4) Then
    ’tARRAY_2 = gPLOT(m  – random(1,3)*(gPath_divisions))(lSEED)(0)
    ’tARRAY_2 = array(0,0,0)
    ’Call Rhino.AddCylinder(gPLOT(m)(lSEED)(0), tARRAY_2, .5)
  End If
 Next
Next
End Function
‘________________________________________ FUNCTION : BUILD 3  ____________________________________________
Function func_BUILD3(gPLOT, gPLOT2, gPLOT3, gPLOT4, gRINGS, gPath_divisions, gYEAR)
Dim lYEAR, sLofter1(), sLofter2(),i, j, k, tArray1(), tArray2(), sLoft_number
sLoft_number = 0
j = 0

For i = 1 to 5 Step 2
 k = 0
 For lYEAR = gPATH_divisions to gYEAR

  Redim tArray1(j)
  Redim tArray2(j)
 ’——– SERIES LOFTER 1 ——
  Call func_BUILD3_sub( i, lYEAR, sLofter1, sLofter2, k, gPLOT, sLoft_number)
  Call func_BUILD3_sub( i, lYEAR, sLofter1, sLofter2, k, gPLOT2, sLoft_number)
  Call func_BUILD3_sub(i, lYEAR, sLofter1, sLofter2, k, gPLOT3, sLoft_number)
  Call func_BUILD3_sub( i, lYEAR, sLofter1, sLofter2, k, gPLOT4, sLoft_number)  

 Next
 Call Rhino.AddLoftSrf(sLofter1) 
 Call Rhino.AddLoftSrf(sLofter2) 
 Call Rhino.DeleteObjects(sLofter1)
 Call Rhino.DeleteObjects(sLofter2)  
Next

End Function
Function func_BUILD3_sub( i, lYEAR, sLofter1, sLofter2, k, gPLOT, sLoft_number)

Dim tArray1(), tArray2(), temp1(2), j, sLoft_thick
If sLoft_number = 0 Then sLoft_thick = 2.5 End If
If sLoft_number = 1 Then sLoft_thick = 2 End If
If sLoft_number = 2 Then sLoft_thick = 2 End If
If sLoft_number = 3 Then sLoft_thick = 2.5 End If
  j =0
  Redim Preserve tArray1(j), tArray2(j)  
  temp1(0) = gPLOT(lYEAR)(0)(i)(0)-(gPLOT(lYEAR)(0)(i)(0) – gPLOT(lYEAR-gPath_divisions)(0)(i)(0))/sLoft_thick
  temp1(1) = gPLOT(lYEAR)(0)(i)(1)-(gPLOT(lYEAR)(0)(i)(1) – gPLOT(lYEAR-gPath_divisions)(0)(i)(1))/sLoft_thick  
  temp1(2) = gPLOT(lYEAR)(0)(i)(2)-(gPLOT(lYEAR)(0)(i)(2) – gPLOT(lYEAR-gPath_divisions)(0)(i)(2))/sLoft_thick
  tArray1(j) = temp1
  temp1(0) = gPLOT(lYEAR-gPath_divisions)(0)(i)(0)+(gPLOT(lYEAR)(0)(i)(0) – gPLOT(lYEAR-gPath_divisions)(0)(i)(0))/sLoft_thick
  temp1(1) = gPLOT(lYEAR-gPath_divisions)(0)(i)(1)+(gPLOT(lYEAR)(0)(i)(1) – gPLOT(lYEAR-gPath_divisions)(0)(i)(1))/sLoft_thick  
  temp1(2) = gPLOT(lYEAR-gPath_divisions)(0)(i)(2)+(gPLOT(lYEAR)(0)(i)(2) – gPLOT(lYEAR-gPath_divisions)(0)(i)(2))/sLoft_thick
  tArray2(j) = temp1
  j = j+1
 ’——–   
  Redim Preserve tArray1(j), tArray2(j)  
  tArray1(j) = gPLOT(lYEAR)(0)(i)
  tArray2(j) = gPLOT(lYEAR-gPath_divisions)(0)(i)  
  j = j+1
 ’——–
  Redim Preserve tArray1(j), tArray2(j)  
  tArray1(j) = gPLOT(lYEAR)(0)(i+1)
  tArray2(j) = gPLOT(lYEAR-gPath_divisions)(0)(i+1)  
  j = j+1
 ’——–
  Redim Preserve tArray1(j), tArray2(j)  
  temp1(0) = gPLOT(lYEAR)(0)(i+1)(0)-(gPLOT(lYEAR)(0)(i+1)(0) – gPLOT(lYEAR-gPath_divisions)(0)(i+1)(0))/sLoft_thick
  temp1(1) = gPLOT(lYEAR)(0)(i+1)(1)-(gPLOT(lYEAR)(0)(i+1)(1) – gPLOT(lYEAR-gPath_divisions)(0)(i+1)(1))/sLoft_thick  
  temp1(2) = gPLOT(lYEAR)(0)(i+1)(2)-(gPLOT(lYEAR)(0)(i+1)(2) – gPLOT(lYEAR-gPath_divisions)(0)(i+1)(2))/sLoft_thick
  tArray1(j) = temp1
  temp1(0) = gPLOT(lYEAR-gPath_divisions)(0)(i+1)(0)+(gPLOT(lYEAR)(0)(i+1)(0) – gPLOT(lYEAR-gPath_divisions)(0)(i+1)(0))/sLoft_thick
  temp1(1) = gPLOT(lYEAR-gPath_divisions)(0)(i+1)(1)+(gPLOT(lYEAR)(0)(i+1)(1) – gPLOT(lYEAR-gPath_divisions)(0)(i+1)(1))/sLoft_thick  
  temp1(2) = gPLOT(lYEAR-gPath_divisions)(0)(i+1)(2)+(gPLOT(lYEAR)(0)(i+1)(2) – gPLOT(lYEAR-gPath_divisions)(0)(i+1)(2))/sLoft_thick
  tArray2(j) = temp1
  j=j+1
  
  
 ’———– LOFT ————
  Redim Preserve sLofter1(k), sLofter2(k)  
  sLofter1(k) = Rhino.AddPolyline(tArray1)
  sLofter2(k) = Rhino.AddPolyline(tArray2)
  k = k+1  
  
  If sLoft_number < 3 Then sLoft_number = sLoft_number+1 Else sLoft_number = 0 End If
  
End Function
‘________________________________________ FUNCTION : lYIELD ____________________________________________
Function func_YIELD(Yield, gPLOT_avg, lYEAR,  i)
 Yield(i) = ( gPLOT_avg(lYEAR) + Random( -0, 0) ) ‘ <— Local Yield
End Function
‘________________________________________ FUNCTION : gYIELD ____________________________________________
Function func_gYIELD(gPLOT_avg, gPLOT_low, gPLOT_high, lYEAR)
 gPLOT_avg(lYEAR) =  Random(gPLOT_low, gPLOT_high)
End Function
‘________________________________________ FUNCTION : RANDOM ____________________________________________
Function Random(low, up) 
 Randomize
 random = ((up – low)* Rnd()) + low ‘ *** take the difference of range
End Function
‘________________________________________ FUNCTION : NEAREST____________________________________________
Function func_NEAR(lPLOT, tPlot, lSEED, lYEAR, gCHECK, gPath_height)
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