(n)certainties – Columbia – Fall 2007

071207_Agritect_v5.16

 07_12-07_final_page_09.jpg

‘########################################################################################################
‘###     AGRITECT version 5.16 : December 07, 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, gPath_r1, gPath_r2
  Dim gCheck, gPLOT_struct, lPi, gRow
  lPi = Rhino.Pi()
‘######################################## GLOBAL PARAMETERS #############################################
 gYEAR = 340               ’<— Global YEARS the system runs
 gPLOT_high = 200          ’<— Yield, High (in bushels per acre)
 gPLOT_low = 150         ’<— Yield, Low  (in bushels per acre)
 gPath_height = 6             ’<— Start floor to floor height (in meters)
 gPath_r1 = 100          ’<— TEMPORARY seed inner radius(start)
 gPath_r2 = 30         ’<— TEMPORARY seed thickness
 gPath_divisions = 18      ’<— Number of “chutes” and seeds
 gRow = 5         ’<— Number of Cornrows
 ’——FIXED VARIABLES——
 gRINGS = 7            ’<— Number of rings  (3 PLOT, 4 INTERSTICE)
 gCheck = gPath_r2 * 3      ’<— Distance to Leech
 gPLOT_struct = (lPi/gPath_divisions)/12  ’<— Structure Width (in rads)
‘########################################################################################################
Call Rhino.EnableRedraw(false)
Call Growth(gYEAR, gRINGS, gPLOT_high, gPLOT_low, gPath_r1, gPath_r2,gPLOT_struct, gRow)
Call Rhino.EnableRedraw(true)
‘________________________________________________________________________________________________________
Sub Growth(gYEAR, gRINGS, gPLOT_high, gPLOT_low, gPath_r1, gPath_r2,gPLOT_struct, gRow)
 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), 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.05 ’<— 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) > 20 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)      
      tArr_2b(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)
      tArr_2c(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)
      tArr_2d(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 ) + tTheta + ( ((2*lPi)/(20*gPath_divisions) )* (tYield_2(i)-(gPLOT_high+gPLOT_low)/2)/(gPLOT_high-(gPLOT_high+gPLOT_low)/2)    )
     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 ) + tTheta + ( ((2*lPi)/(20*gPath_divisions) )* (tYield_2(i)-(gPLOT_high+gPLOT_low)/2)/(gPLOT_high-(gPLOT_high+gPLOT_low)/2)    )
     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_BUILD2(gPLOT, gRINGS, gPath_divisions, gYEAR)
Call func_BUILD3(gPLOT, gPLOT2, gPLOT3, gPLOT4, gRINGS, gPath_divisions, gYEAR, gSEED, gPLOT_gYield, gPLOT_high, gPLOT_low, gRow)

End Sub

‘________________________________________ FUNCTION : BUILD 2  ____________________________________________
Function func_BUILD2(gPLOT, gRINGS, gPath_divisions, gYEAR)
Dim lYEAR, tARRAY(4), sLofter(), m, k, lSEED
lSEED = 0

For m = 1 to 3
 k = 0
 For lYEAR = 1 to gYEAR
If lYear > gPath_divisions Then
  tARRAY(0) = gPLOT(lYEAR)(lSEED)(m*2)
  tARRAY(1) = gPLOT(lYEAR)(lSEED)(m*2-1) 
  tARRAY(2) = array( gPLOT(lYEAR)(lSEED)(m*2-1)(0), gPLOT(lYEAR)(lSEED)(m*2-1)(1), (gPLOT(lYEAR)(lSEED)(m*2-1)(2)-1) )
  tARRAY(3) = array( gPLOT(lYEAR)(lSEED)(m*2)(0), gPLOT(lYEAR)(lSEED)(m*2)(1), (gPLOT(lYEAR)(lSEED)(m*2)(2)-1) )
  tARRAY(2) = gPLOT(lYEAR-gPath_Divisions)(lSEED)(m*2-1)
  tARRAY(3) = gPLOT(lYEAR-gPath_divisions)(lSEED)(m*2)

  tARRAY(4) = gPLOT(lYEAR)(lSEED)(m*2)
  Redim Preserve sLofter(k)  
  sLofter(k) = Rhino.AddPolyline(tARRAY)
  k = k + 1 
End If
 Next
 
 Call Rhino.AddLoftSrf(sLofter)  
Next
End Function
‘________________________________________ FUNCTION : BUILD 3  ____________________________________________
Function func_BUILD3(gPLOT, gPLOT2, gPLOT3, gPLOT4, gRINGS, gPath_divisions, gYEAR, gSEED, gPLOT_gYield, gPLOT_high, gPLOT_low, gRow)
Dim lYEAR, sLofter1(), sLofter2(), sLofter3(), sLofter4(), i, j, k, p, h, tArray1(1), tArray2(1), sLoft_number, check_int, lSEED, lSEED_trigger
sLoft_number = 0
j = 0
For lSEED = 0 to gSEED
  For i = 1 to 5 Step 2
 k = 0
 h = 0
 sLoft_number = 0 
 lSEED_trigger = 0
 For lYEAR = gPATH_divisions to gYEAR
 If gPLOT(lYEAR)(lSEED)(0)(0) <> 0 And gPLOT(lYEAR)(lSEED)(0)(1) <> 0 And gPLOT(lYEAR)(lSEED)(0)(2) <> 0 Then
 ’——– SERIES LOFTER 1 ——
  If lSEED = 0 Then
   Call func_BUILD3_sub( i, lYEAR, sLofter1, sLofter2, sLofter3, sLofter4,k, gPLOT, sLoft_number, lSEED, gPLOT_gYield, gPLOT_high, gPLOT_low, gYEAR)
   Call func_BUILD3_sub( i, lYEAR, sLofter1, sLofter2, sLofter3, sLofter4,k, gPLOT2, sLoft_number, lSEED, gPLOT_gYield, gPLOT_high, gPLOT_low, gYEAR)
   Call func_BUILD3_sub( i, lYEAR, sLofter1, sLofter2, sLofter3, sLofter4,k, gPLOT3, sLoft_number, lSEED, gPLOT_gYield, gPLOT_high, gPLOT_low, gYEAR)
   Call func_BUILD3_sub( i, lYEAR, sLofter1, sLofter2, sLofter3, sLofter4,k, gPLOT4, sLoft_number, lSEED, gPLOT_gYield, gPLOT_high, gPLOT_low, gYEAR)
  Else
   If lSEED_trigger > gPath_divisions Then
    Call func_BUILD3_sub( i, lYEAR, sLofter1, sLofter2, sLofter3, sLofter4,k, gPLOT, sLoft_number, lSEED, gPLOT_gYield, gPLOT_high, gPLOT_low, gYEAR)
    Call func_BUILD3_sub( i, lYEAR, sLofter1, sLofter2, sLofter3, sLofter4,k, gPLOT2, sLoft_number, lSEED, gPLOT_gYield, gPLOT_high, gPLOT_low, gYEAR)
    Call func_BUILD3_sub( i, lYEAR, sLofter1, sLofter2, sLofter3, sLofter4,k, gPLOT3, sLoft_number, lSEED, gPLOT_gYield, gPLOT_high, gPLOT_low, gYEAR)
    Call func_BUILD3_sub( i, lYEAR, sLofter1, sLofter2, sLofter3, sLofter4,k, gPLOT4, sLoft_number, lSEED, gPLOT_gYield, gPLOT_high, gPLOT_low, gYEAR)
   Else
    lSEED_trigger = lSEED_trigger + 1
   End If
  End If 
  End If 
 Next
 Call Rhino.AddLoftSrf(sLofter3)
 Call Rhino.AddLoftSrf(sLofter4)
 ’— 
 Call Rhino.DeleteObjects(sLofter3)
 Call Rhino.DeleteObjects(sLofter4) 
  Next
Next
Call func_BUILD3_soil(gPLOT, gPLOT2, gPLOT3, gPLOT4, gPath_divisions, gYEAR, gRow)
End Function
‘________________________________________ FUNCTION : BUILD 3 Sub________________________________________
Function func_BUILD3_sub( i, lYEAR, sLofter1, sLofter2, sLofter3, sLofter4, k, gPLOT, sLoft_number, lSEED, gPLOT_gYield, gPLOT_high, gPLOT_low, gYEAR)
Dim tArray1(), tArray2(), tArray3(), temp1(2), temp2(2), temp3(2), j, sLoft_thick
If sLoft_number = 0 Then
 sLoft_thick = (2.2 – 1.9)*(gPLOT_gYield(lYEAR)-gPLOT_low)/(gPLOT_high-gPLOT_low) + 1.9
End If
If sLoft_number = 1 Then
 sLoft_thick = 1.9
End If
If sLoft_number = 2 Then
sLoft_thick = 1.9
End If
If sLoft_number = 3 Then
 If lYear = gYear Then
 sLoft_thick = (2.2 – 1.9)*(gPLOT_gYield(lYEAR)-gPLOT_low)/(gPLOT_high-gPLOT_low) + 1.9
 Else
 sLoft_thick = (2.2 – 1.9)*(gPLOT_gYield(lYEAR+1)-gPLOT_low)/(gPLOT_high-gPLOT_low) + 1.9
 End If 
End If
  j =0
 ’————————————————————————————-  
  Redim Preserve tArray1(j), tArray2(j) 
  If i = 1 Then
    temp1(0) = gPLOT(lYEAR)(lSEED)(i)(0)-(gPLOT(lYEAR)(lSEED)(i)(0) – gPLOT(lYEAR-gPath_divisions)(lSEED)(i)(0))/sLoft_thick
       temp1(1) = gPLOT(lYEAR)(lSEED)(i)(1)-(gPLOT(lYEAR)(lSEED)(i)(1) – gPLOT(lYEAR-gPath_divisions)(lSEED)(i)(1))/sLoft_thick  
    temp1(2) = gPLOT(lYEAR)(lSEED)(i)(2)-(gPLOT(lYEAR)(lSEED)(i)(2) – gPLOT(lYEAR-gPath_divisions)(lSEED)(i)(2))/sLoft_thick  
    temp2(0) = gPLOT(lYEAR)(lSEED)(i+1)(0)-(gPLOT(lYEAR)(lSEED)(i+1)(0) – gPLOT(lYEAR-gPath_divisions)(lSEED)(i+1)(0))/sLoft_thick
       temp2(1) = gPLOT(lYEAR)(lSEED)(i+1)(1)-(gPLOT(lYEAR)(lSEED)(i+1)(1) – gPLOT(lYEAR-gPath_divisions)(lSEED)(i+1)(1))/sLoft_thick  
    temp2(2) = gPLOT(lYEAR)(lSEED)(i+1)(2)-(gPLOT(lYEAR)(lSEED)(i+1)(2) – gPLOT(lYEAR-gPath_divisions)(lSEED)(i+1)(2))/sLoft_thick  
    temp3(0) = temp1(0) – (temp1(0) – temp2(0))/5
    temp3(1) = temp1(1) – (temp1(1) – temp2(1))/5
    temp3(2) = temp1(2) – (temp1(2) – temp2(2))/5
  Else
  temp1(0) = gPLOT(lYEAR)(lSEED)(i)(0)-(gPLOT(lYEAR)(lSEED)(i)(0) – gPLOT(lYEAR-gPath_divisions)(lSEED)(i)(0))/sLoft_thick
  temp1(1) = gPLOT(lYEAR)(lSEED)(i)(1)-(gPLOT(lYEAR)(lSEED)(i)(1) – gPLOT(lYEAR-gPath_divisions)(lSEED)(i)(1))/sLoft_thick  
  temp1(2) = gPLOT(lYEAR)(lSEED)(i)(2)-(gPLOT(lYEAR)(lSEED)(i)(2) – gPLOT(lYEAR-gPath_divisions)(lSEED)(i)(2))/sLoft_thick
  temp2(0) = gPLOT(lYEAR)(lSEED)(i-1)(0)-(gPLOT(lYEAR)(lSEED)(i-1)(0) – gPLOT(lYEAR-gPath_divisions)(lSEED)(i-1)(0))/sLoft_thick
  temp2(1) = gPLOT(lYEAR)(lSEED)(i-1)(1)-(gPLOT(lYEAR)(lSEED)(i-1)(1) – gPLOT(lYEAR-gPath_divisions)(lSEED)(i-1)(1))/sLoft_thick  
  temp2(2) = gPLOT(lYEAR)(lSEED)(i-1)(2)-(gPLOT(lYEAR)(lSEED)(i-1)(2) – gPLOT(lYEAR-gPath_divisions)(lSEED)(i-1)(2))/sLoft_thick

  temp3(0) = temp1(0) – (temp1(0) – temp2(0))/sLoft_thick
  temp3(1) = temp1(1) – (temp1(1) – temp2(1))/sLoft_thick
  temp3(2) = temp1(2) – (temp1(2) – temp2(2))/sLoft_thick
  End If
  tArray1(j) = temp3
  ’———————
  If i = 5 Then
    temp1(0) = gPLOT(lYEAR-gPath_divisions)(lSEED)(i+1)(0)-(gPLOT(lYEAR-gPath_divisions)(lSEED)(i+1)(0) – gPLOT(lYEAR)(lSEED)(i+1)(0))/sLoft_thick
    temp1(1) = gPLOT(lYEAR-gPath_divisions)(lSEED)(i+1)(1)-(gPLOT(lYEAR-gPath_divisions)(lSEED)(i+1)(1) – gPLOT(lYEAR)(lSEED)(i+1)(1))/sLoft_thick  
    temp1(2) = gPLOT(lYEAR-gPath_divisions)(lSEED)(i+1)(2)-(gPLOT(lYEAR-gPath_divisions)(lSEED)(i+1)(2) – gPLOT(lYEAR)(lSEED)(i+1)(2))/sLoft_thick
    temp2(0) = gPLOT(lYEAR-gPath_divisions)(lSEED)(i)(0)-(gPLOT(lYEAR-gPath_divisions)(lSEED)(i)(0) – gPLOT(lYEAR)(lSEED)(i)(0))/sLoft_thick
    temp2(1) = gPLOT(lYEAR-gPath_divisions)(lSEED)(i)(1)-(gPLOT(lYEAR-gPath_divisions)(lSEED)(i)(1) – gPLOT(lYEAR)(lSEED)(i)(1))/sLoft_thick  
    temp2(2) = gPLOT(lYEAR-gPath_divisions)(lSEED)(i)(2)-(gPLOT(lYEAR-gPath_divisions)(lSEED)(i)(2) – gPLOT(lYEAR)(lSEED)(i)(2))/sLoft_thick
    temp3(0) = temp1(0) – (temp1(0) – temp2(0))/5
    temp3(1) = temp1(1) – (temp1(1) – temp2(1))/5
    temp3(2) = temp1(2) – (temp1(2) – temp2(2))/5
  Else
  temp1(0) = gPLOT(lYEAR-gPath_divisions)(lSEED)(i+1)(0)-(gPLOT(lYEAR-gPath_divisions)(lSEED)(i+1)(0) – gPLOT(lYEAR)(lSEED)(i+1)(0))/sLoft_thick
  temp1(1) = gPLOT(lYEAR-gPath_divisions)(lSEED)(i+1)(1)-(gPLOT(lYEAR-gPath_divisions)(lSEED)(i+1)(1) – gPLOT(lYEAR)(lSEED)(i+1)(1))/sLoft_thick  
  temp1(2) = gPLOT(lYEAR-gPath_divisions)(lSEED)(i+1)(2)-(gPLOT(lYEAR-gPath_divisions)(lSEED)(i+1)(2) – gPLOT(lYEAR)(lSEED)(i+1)(2))/sLoft_thick
  temp2(0) = gPLOT(lYEAR-gPath_divisions)(lSEED)(i+2)(0)-(gPLOT(lYEAR-gPath_divisions)(lSEED)(i+2)(0) – gPLOT(lYEAR)(lSEED)(i+2)(0))/sLoft_thick
  temp2(1) = gPLOT(lYEAR-gPath_divisions)(lSEED)(i+2)(1)-(gPLOT(lYEAR-gPath_divisions)(lSEED)(i+2)(1) – gPLOT(lYEAR)(lSEED)(i+2)(1))/sLoft_thick  
  temp2(2) = gPLOT(lYEAR-gPath_divisions)(lSEED)(i+2)(2)-(gPLOT(lYEAR-gPath_divisions)(lSEED)(i+2)(2) – gPLOT(lYEAR)(lSEED)(i+2)(2))/sLoft_thick
  
  temp3(0) = temp1(0) – (temp1(0) – temp2(0))/sLoft_thick
  temp3(1) = temp1(1) – (temp1(1) – temp2(1))/sLoft_thick
  temp3(2) = temp1(2) – (temp1(2) – temp2(2))/sLoft_thick
  End If
  tArray2(j) = temp3
  j = j+1
 ’————————————————————————————-
  Redim Preserve tArray1(j), tArray2(j)  
  temp3(0) = gPLOT(lYEAR)(lSEED)(i)(0)-(gPLOT(lYEAR)(lSEED)(i)(0) – gPLOT(lYEAR-gPath_divisions)(lSEED)(i)(0))/8
  temp3(1) = gPLOT(lYEAR)(lSEED)(i)(1)-(gPLOT(lYEAR)(lSEED)(i)(1) – gPLOT(lYEAR-gPath_divisions)(lSEED)(i)(1))/8  
  temp3(2) = gPLOT(lYEAR)(lSEED)(i)(2)-(gPLOT(lYEAR)(lSEED)(i)(2) – gPLOT(lYEAR-gPath_divisions)(lSEED)(i)(2))/8
  tArray1(j) = temp3
  temp3(0) = gPLOT(lYEAR-gPath_divisions)(lSEED)(i+1)(0)-(gPLOT(lYEAR-gPath_divisions)(lSEED)(i+1)(0) – gPLOT(lYEAR)(lSEED)(i+1)(0))/8
  temp3(1) = gPLOT(lYEAR-gPath_divisions)(lSEED)(i+1)(1)-(gPLOT(lYEAR-gPath_divisions)(lSEED)(i+1)(1) – gPLOT(lYEAR)(lSEED)(i+1)(1))/8  
  temp3(2) = gPLOT(lYEAR-gPath_divisions)(lSEED)(i+1)(2)-(gPLOT(lYEAR-gPath_divisions)(lSEED)(i+1)(2) – gPLOT(lYEAR)(lSEED)(i+1)(2))/8
  tArray2(j) = temp3 
  j = j+1 
 ’————————————————————————————-
  Redim Preserve tArray1(j), tArray2(j)  
  tArray1(j) = gPLOT(lYEAR)(lSEED)(i) 
  tArray2(j) = gPLOT(lYEAR-gPath_divisions)(lSEED)(i+1) 
  j = j+1
 ’————————————————————————————-  
  Redim Preserve tArray1(j), tArray2(j)  

  temp3(0) = gPLOT(lYEAR)(lSEED)(i+1)(0)-(gPLOT(lYEAR)(lSEED)(i+1)(0) – gPLOT(lYEAR)(lSEED)(i)(0))/20
  temp3(1) = gPLOT(lYEAR)(lSEED)(i+1)(1)-(gPLOT(lYEAR)(lSEED)(i+1)(1) – gPLOT(lYEAR)(lSEED)(i)(1))/20  
  temp3(2) = gPLOT(lYEAR)(lSEED)(i+1)(2)-(gPLOT(lYEAR)(lSEED)(i+1)(2) – gPLOT(lYEAR)(lSEED)(i)(2))/20
  tArray1(j) = temp3
  temp3(0) = gPLOT(lYEAR-gPath_divisions)(lSEED)(i)(0)-(gPLOT(lYEAR-gPath_divisions)(lSEED)(i)(0) – gPLOT(lYEAR-gPath_divisions)(lSEED)(i+1)(0))/20
  temp3(1) = gPLOT(lYEAR-gPath_divisions)(lSEED)(i)(1)-(gPLOT(lYEAR-gPath_divisions)(lSEED)(i)(1) – gPLOT(lYEAR-gPath_divisions)(lSEED)(i+1)(1))/20  
  temp3(2) = gPLOT(lYEAR-gPath_divisions)(lSEED)(i)(2)-(gPLOT(lYEAR-gPath_divisions)(lSEED)(i)(2) – gPLOT(lYEAR-gPath_divisions)(lSEED)(i+1)(2))/20
  tArray2(j) = temp3  
  j = j+1  
   
 ’————————————————————————————-
  Redim Preserve tArray1(j), tArray2(j) 
  tArray1(j) = gPLOT(lYEAR)(lSEED)(i+1)  
  tArray2(j) = gPLOT(lYEAR-gPath_divisions)(lSEED)(i)    
  j = j+1
 ’————————————————————————————-
  Redim Preserve tArray1(j), tArray2(j)  
  temp3(0) = gPLOT(lYEAR)(lSEED)(i+1)(0)-(gPLOT(lYEAR)(lSEED)(i+1)(0) – gPLOT(lYEAR-gPath_divisions)(lSEED)(i+1)(0))/8
  temp3(1) = gPLOT(lYEAR)(lSEED)(i+1)(1)-(gPLOT(lYEAR)(lSEED)(i+1)(1) – gPLOT(lYEAR-gPath_divisions)(lSEED)(i+1)(1))/8  
  temp3(2) = gPLOT(lYEAR)(lSEED)(i+1)(2)-(gPLOT(lYEAR)(lSEED)(i+1)(2) – gPLOT(lYEAR-gPath_divisions)(lSEED)(i+1)(2))/8
  tArray1(j) = temp3
  temp3(0) = gPLOT(lYEAR-gPath_divisions)(lSEED)(i)(0)-(gPLOT(lYEAR-gPath_divisions)(lSEED)(i)(0) – gPLOT(lYEAR)(lSEED)(i)(0))/8
  temp3(1) = gPLOT(lYEAR-gPath_divisions)(lSEED)(i)(1)-(gPLOT(lYEAR-gPath_divisions)(lSEED)(i)(1) – gPLOT(lYEAR)(lSEED)(i)(1))/8  
  temp3(2) = gPLOT(lYEAR-gPath_divisions)(lSEED)(i)(2)-(gPLOT(lYEAR-gPath_divisions)(lSEED)(i)(2) – gPLOT(lYEAR)(lSEED)(i)(2))/8
  tArray2(j) = temp3 
  j = j+1   
 ’————————————————————————————-
  Redim Preserve tArray1(j), tArray2(j)
  If i = 5 Then
  temp1(0) = gPLOT(lYEAR)(lSEED)(i+1)(0)-(gPLOT(lYEAR)(lSEED)(i+1)(0) – gPLOT(lYEAR-gPath_divisions)(lSEED)(i+1)(0))/sLoft_thick
  temp1(1) = gPLOT(lYEAR)(lSEED)(i+1)(1)-(gPLOT(lYEAR)(lSEED)(i+1)(1) – gPLOT(lYEAR-gPath_divisions)(lSEED)(i+1)(1))/sLoft_thick  
  temp1(2) = gPLOT(lYEAR)(lSEED)(i+1)(2)-(gPLOT(lYEAR)(lSEED)(i+1)(2) – gPLOT(lYEAR-gPath_divisions)(lSEED)(i+1)(2))/sLoft_thick
  temp2(0) = gPLOT(lYEAR)(lSEED)(i)(0)-(gPLOT(lYEAR)(lSEED)(i)(0) – gPLOT(lYEAR-gPath_divisions)(lSEED)(i)(0))/sLoft_thick
  temp2(1) = gPLOT(lYEAR)(lSEED)(i)(1)-(gPLOT(lYEAR)(lSEED)(i)(1) – gPLOT(lYEAR-gPath_divisions)(lSEED)(i)(1))/sLoft_thick  
  temp2(2) = gPLOT(lYEAR)(lSEED)(i)(2)-(gPLOT(lYEAR)(lSEED)(i)(2) – gPLOT(lYEAR-gPath_divisions)(lSEED)(i)(2))/sLoft_thick
    temp3(0) = temp1(0) – (temp1(0) – temp2(0))/5
    temp3(1) = temp1(1) – (temp1(1) – temp2(1))/5
    temp3(2) = temp1(2) – (temp1(2) – temp2(2))/2
  Else  
  temp1(0) = gPLOT(lYEAR)(lSEED)(i+1)(0)-(gPLOT(lYEAR)(lSEED)(i+1)(0) – gPLOT(lYEAR-gPath_divisions)(lSEED)(i+1)(0))/sLoft_thick
  temp1(1) = gPLOT(lYEAR)(lSEED)(i+1)(1)-(gPLOT(lYEAR)(lSEED)(i+1)(1) – gPLOT(lYEAR-gPath_divisions)(lSEED)(i+1)(1))/sLoft_thick  
  temp1(2) = gPLOT(lYEAR)(lSEED)(i+1)(2)-(gPLOT(lYEAR)(lSEED)(i+1)(2) – gPLOT(lYEAR-gPath_divisions)(lSEED)(i+1)(2))/sLoft_thick

  temp2(0) = gPLOT(lYEAR)(lSEED)(i+2)(0)-(gPLOT(lYEAR)(lSEED)(i+2)(0) – gPLOT(lYEAR-gPath_divisions)(lSEED)(i+2)(0))/sLoft_thick
  temp2(1) = gPLOT(lYEAR)(lSEED)(i+2)(1)-(gPLOT(lYEAR)(lSEED)(i+2)(1) – gPLOT(lYEAR-gPath_divisions)(lSEED)(i+2)(1))/sLoft_thick  
  temp2(2) = gPLOT(lYEAR)(lSEED)(i+2)(2)-(gPLOT(lYEAR)(lSEED)(i+2)(2) – gPLOT(lYEAR-gPath_divisions)(lSEED)(i+2)(2))/sLoft_thick

  temp3(0) = temp1(0) – (temp1(0) – temp2(0))/sLoft_thick
  temp3(1) = temp1(1) – (temp1(1) – temp2(1))/sLoft_thick
  temp3(2) = temp1(2) – (temp1(2) – temp2(2))/sLoft_thick
  End If
  tArray1(j) = temp3
  ’———————
  If i = 1 Then
  temp1(0) = gPLOT(lYEAR-gPath_divisions)(lSEED)(i)(0)-(gPLOT(lYEAR-gPath_divisions)(lSEED)(i)(0) – gPLOT(lYEAR)(lSEED)(i)(0))/sLoft_thick
  temp1(1) = gPLOT(lYEAR-gPath_divisions)(lSEED)(i)(1)-(gPLOT(lYEAR-gPath_divisions)(lSEED)(i)(1) – gPLOT(lYEAR)(lSEED)(i)(1))/sLoft_thick  
  temp1(2) = gPLOT(lYEAR-gPath_divisions)(lSEED)(i)(2)-(gPLOT(lYEAR-gPath_divisions)(lSEED)(i)(2) – gPLOT(lYEAR)(lSEED)(i)(2))/sLoft_thick
  temp2(0) = gPLOT(lYEAR-gPath_divisions)(lSEED)(i+1)(0)-(gPLOT(lYEAR-gPath_divisions)(lSEED)(i+1)(0) – gPLOT(lYEAR)(lSEED)(i+1)(0))/sLoft_thick
  temp2(1) = gPLOT(lYEAR-gPath_divisions)(lSEED)(i+1)(1)-(gPLOT(lYEAR-gPath_divisions)(lSEED)(i+1)(1) – gPLOT(lYEAR)(lSEED)(i+1)(1))/sLoft_thick  
  temp2(2) = gPLOT(lYEAR-gPath_divisions)(lSEED)(i+1)(2)-(gPLOT(lYEAR-gPath_divisions)(lSEED)(i+1)(2) – gPLOT(lYEAR)(lSEED)(i+1)(2))/sLoft_thick
  temp3(0) = temp1(0) – (temp1(0) – temp2(0))/5
  temp3(1) = temp1(1) – (temp1(1) – temp2(1))/5
  temp3(2) = temp1(2) – (temp1(2) – temp2(2))/5
  Else
  temp1(0) = gPLOT(lYEAR-gPath_divisions)(lSEED)(i)(0)-(gPLOT(lYEAR-gPath_divisions)(lSEED)(i)(0) – gPLOT(lYEAR)(lSEED)(i)(0))/sLoft_thick
  temp1(1) = gPLOT(lYEAR-gPath_divisions)(lSEED)(i)(1)-(gPLOT(lYEAR-gPath_divisions)(lSEED)(i)(1) – gPLOT(lYEAR)(lSEED)(i)(1))/sLoft_thick  
  temp1(2) = gPLOT(lYEAR-gPath_divisions)(lSEED)(i)(2)-(gPLOT(lYEAR-gPath_divisions)(lSEED)(i)(2) – gPLOT(lYEAR)(lSEED)(i)(2))/sLoft_thick

  temp2(0) = gPLOT(lYEAR-gPath_divisions)(lSEED)(i-1)(0)-(gPLOT(lYEAR-gPath_divisions)(lSEED)(i-1)(0) – gPLOT(lYEAR)(lSEED)(i-1)(0))/sLoft_thick
  temp2(1) = gPLOT(lYEAR-gPath_divisions)(lSEED)(i-1)(1)-(gPLOT(lYEAR-gPath_divisions)(lSEED)(i-1)(1) – gPLOT(lYEAR)(lSEED)(i-1)(1))/sLoft_thick  
  temp2(2) = gPLOT(lYEAR-gPath_divisions)(lSEED)(i-1)(2)-(gPLOT(lYEAR-gPath_divisions)(lSEED)(i-1)(2) – gPLOT(lYEAR)(lSEED)(i-1)(2))/sLoft_thick
  
  temp3(0) = temp1(0) – (temp1(0) – temp2(0))/sLoft_thick
  temp3(1) = temp1(1) – (temp1(1) – temp2(1))/sLoft_thick
  temp3(2) = temp1(2) – (temp1(2) – temp2(2))/sLoft_thick
  End If
  tArray2(j) = temp3
  j=j+1
 ’————————————————————————————-  

  Redim Preserve sLofter1(k), sLofter2(k), sLofter3(k), sLofter4(k)  
  sLofter3(k) = Rhino.Addcurve(tArray1)
  sLofter4(k) = Rhino.Addcurve(tArray2)  
  k = k+1  

  If sLoft_number < 3 Then
  sLoft_number = sLoft_number+1
  Else sLoft_number = 0 End If
  
End Function
‘________________________________________ FUNCTION : BUILD 3 Soil ________________________________________
Function func_BUILD3_soil(gPLOT, gPLOT2, gPLOT3, gPLOT4, gPath_divisions, gYEAR, gRow)

Dim i, j, k, sLofter(), lYEAR, tArray(), tRow
For i = 1 to 5 Step 2
 For tRow = 0 to (gRow-1)
 j = 0
 For lYear = gYEAR to (gYEAR – gPath_divisions  ) Step -1
  Call func_BUILD3_soilsub(gPLOT4, lYEAR, i, sLofter, j, tRow, gRow)
  Call func_BUILD3_soilsub(gPLOT3, lYEAR, i, sLofter, j, tRow, gRow)
  Call func_BUILD3_soilsub(gPLOT2, lYEAR, i, sLofter, j, tRow, gRow)
  Call func_BUILD3_soilsub(gPLOT, lYEAR, i, sLofter, j, tRow, gRow)
 Next
 
 Call Rhino.AddLoftSrf(sLofter) 
 Call Rhino.DeleteObjects(sLofter)
 Next
Next
End Function
‘________________________________________ FUNCTION : BUILD 3 SoilSub ___________________________________
Function func_BUILD3_soilsub(gPLOT, lYEAR, i, sLofter, j, tRow, gRow)
Dim k, tARRAY(), temp(2)
 k = 0
  Redim Preserve tArray(k)
  temp(0) = gPLOT(lYEAR)(0)(i)(0) – (tRow+1)*((gPLOT(lYEAR)(0)(i)(0)- gPLOT(lYEAR)(0)(i+1)(0))/gRow)
  temp(1) = gPLOT(lYEAR)(0)(i)(1) – (tRow+1)*((gPLOT(lYEAR)(0)(i)(1)- gPLOT(lYEAR)(0)(i+1)(1))/gRow)
  temp(2) = gPLOT(lYEAR)(0)(i)(2) – (tRow+1)*((gPLOT(lYEAR)(0)(i)(2)- gPLOT(lYEAR)(0)(i+1)(2))/gRow) 
  tARRAY(k) = temp
  k = k+1 
  ’——-
  Redim Preserve tArray(k)
  temp(0) = gPLOT(lYEAR)(0)(i)(0) – tRow*((gPLOT(lYEAR)(0)(i)(0)- gPLOT(lYEAR)(0)(i+1)(0))/gRow)
  temp(1) = gPLOT(lYEAR)(0)(i)(1) – tRow*((gPLOT(lYEAR)(0)(i)(1)- gPLOT(lYEAR)(0)(i+1)(1))/gRow)
  temp(2) = gPLOT(lYEAR)(0)(i)(2) – tRow*((gPLOT(lYEAR)(0)(i)(2)- gPLOT(lYEAR)(0)(i+1)(2))/gRow) 
  tARRAY(k) = temp   
  k = k+1 
  ’——- 
  Redim Preserve sLofter(j)
  sLofter(j) = Rhino.Addcurve(tArray)
  j = j+1 
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)
 Dim tYEAR, tSEED, dHOLD, dCHECK_z, dCHECK_xy, holdSEED, holdYEAR, tPoint, tPoint2(2)
 dHOLD = 10000000
 
 For tYEAR = 0 to (uBound(lPLOT)-1)
  For tSEED = 0 to uBound( lPLOT(tYEAR) )
   If tSEED <> lSEED  And lPLOT(tYEAR)(tSEED)(0)(2) > tPLOT(0)(2)Then
    dCHECK_xy = Rhino.Distance( array(lPLOT(tYEAR)(tSEED)(0)(0), lPLOT(tYEAR)(tSEED)(0)(1), 0), array(tPLOT(0)(0), tPLOT(0)(1), 0) )
    dCHECK_z = abs( lPLOT(tYEAR)(tSEED)(0)(2) – tPLOT(0)(2) )
    
    If dCHECK_xy > 0 And dCHECK_xy < gCHECK And dCHECK_xy < dHOLD And dCHECK_z < (gPath_height * .5) Then
     dHOLD = dCHECK_xy
     tPoint = lPLOT(tYEAR)(tSEED)(0)
     holdSEED = tSEED
     holdYEAR = tYEAR   
    End If
   End If
  Next
 Next
 ’—–
 If dHOLD < 10000000 Then
   ’If Rhino.Distance(tPoint, gSEED_start(lSEED)) < Rhino.Distance(tPLOT(0), gSEED_start(lSEED)) Then
   tPLOT(0) = tPoint
   
  ’ Else
   ’Call Rhino.AddCylinder(tPoint, tPLOT(0), 1 )
 End If
End Function

1 Comment

1 response so far ↓

Leave a Comment