071012_Agritect_v3.1

 07_10-15_script01.jpg 

Option Explicit
Dim gPath_divisions, gPath_r, gPath_height, gYears, gRings, gStart_x, gStart_y
Dim gPLOT_yield, gPLOT_low, gPLOT_high, Ptemp_x, Ptemp_y, gSEED, gCent_r, gCHECK
 Redim Ptemp_x(gYears)
 Redim Ptemp_x(gRings)
 
‘#################################### PARAMETERS #########################################
 gPath_divisions = 20 ‘ <– Number of Years for one cycle
 gPath_r = 40   ‘ <– Radius of entire structure (base radius)
 gCent_r = 5    ‘ <– Radius of center opening
 gRings = 9    ‘ <– Number of CONCENTRIC rings from center
 gPath_height = .4   ‘ <– HEIGHT OF EACH CHANGE IN ITERATION
 gYEARS = 483    ‘ <– NUMBER OF YEARS OF GROWTH
 gPLOT_high = 200   ‘ <– Maximum Yield 
 gPLOT_low = 130   ‘ <– Minimum Yield

 gSEED = 0    ‘ <– Number of ‘towers’
 gCHECK = 100    ‘ <– Distance of connection  !!! NOT WORKING YET !!!
‘#########################################################################################

Call Rhino.EnableRedraw(false)
Call Growth(gPath_divisions, gPath_r, gPath_height, gYears, gRings, gPLOT_high, gPLOT_low,gSEED, gCent_r)
Call Rhino.EnableRedraw(true)

‘################################# GROWTH FUNCTION #######################################
Sub Growth(gPath_divisions, gPath_r, gPath_height, gYears, gRings, gPLOT_high, gPLOT_low, gSEED, gCent_r)

 Dim Path(2), Path_theta, gPLOT(), gSEED_start(), lYEAR, Ptemp_x(), Ptemp_y(), Ptemp_z(), i, sLofter_1
 Dim sLofter_2, gPLOT_yield(), gPLOT_avg(), lTemp(2), SURFtemp, Struct_height, lSEED, temp_Distance
 
 Redim Ptemp_z(gYEARS)
 Redim Ptemp_x(gRings)
 Redim Ptemp_y(2)
 Redim gPLOT_avg(gYEARS)
 lYEAR = 0

 ‘ —- Establish Array for each Seed —
 For lSEED = 0 to gSEED 
  Redim Preserve gPLOT(lSEED)
  ReDim Preserve gPLOT_yield(lSEED)
  Redim Preserve gPLOT_start(lSEED)
  gPLOT(lSEED) = Ptemp_z
  gPLOT_yield(lSEED) = Ptemp_z

  gPLOT_start(lSEED)= Ptemp_y
 
  gPLOT_start(lSEED)(0) = random(0, 0)
  gPLOT_start(lSEED)(1) = random(0, 0)
 Next
 lSEED = 0
 ‘____________________________________________________________________________________
 For Path_theta = 0 to (6.28/gPath_divisions * gYEARS) Step (6.28/gPath_divisions)
 ‘Call Rhino.EnableRedraw(false)

 For lSEED = 0 to gSEED
  gPLOT(lSEED)(lYEAR) = Ptemp_x

  gPLOT_yield(lSEED)(lYEAR) = Ptemp_x
  gPLOT_avg(lYEAR) = Random(gPLOT_low, gPLOT_high)

  ‘________________________________________________________________________________
  
  For i = 0 to gRings

   gPLOT(lSEED)(lYEAR)(i) = Ptemp_y
   Call func_YIELD(gPLOT_yield,  lYEAR, Ptemp_x, Ptemp_y, i, gPLOT_avg, lSEED)
   
   ‘ ——- Z : VERTICAL in relation to YIELD ———————————   
   If lYEAR = 0 Then
    gPLOT(lSEED)(lYEAR)(i)(2) = 0
   Else    
    If lYEAR > gPath_divisions Then
     gPLOT(lSEED)(lYEAR)(i)(2) = ( gPATH_divisions * gPath_height ) * (gPLOT_yield(lSEED)(lYEAR)(i)/((gPLOT_high+gPLOT_low)/2))  + gPLOT(lSEED)(lYEAR-gPath_divisions)(i)(2)
    Else
     gPLOT(lSEED)(lYEAR)(i)(2) = ( (gPLOT_yield(lSEED)(lYEAR)(i)/((gPLOT_high+gPLOT_low)/2)) * gPath_height *gPath_divisions ) – gPath_height * gPath_divisions + gPath_height * lYEAR
    End If    
   End If  
   ‘ —————- XY Position ———————————————-
   If lYEAR > gPath_divisions And i < (gRings-1) Then ‘All levels above first
        
     temp_Distance = Rhino.Distance(gPLOT(lSEED)(lYEAR – gPATH_divisions)(gRings), gPLOT(lSEED)(lYEAR – gPATH_divisions)(0))
     gPath_r =  temp_Distance  * (  gPLOT_avg(lYEAR)/((gPLOT_high + gPLOT_low)/2) )
    If i = 0 Then
     gPLOT(lSEED)(lYEAR)(i)(0) = (Cos(Path_theta) * ((gRings – i) /gRings) * gPath_r) + gPLOT_start(lSEED)(0)
     gPLOT(lSEED)(lYEAR)(i)(1) = (Sin(Path_theta) * ((gRings – i) /gRings) * gPath_r) + gPLOT_start(lSEED)(1)
     Call func_NEAR(lYEAR, lSEED, i, gPLOT, gCHECK)

    Else
     temp_Distance = Rhino.Distance( array(gPLOT(lSEED)(lYEAR – gPATH_divisions)(gRings)(0), gPLOT(lSEED)(lYEAR – gPATH_divisions)(gRings)(1), gPLOT(lSEED)(lYEAR)(0)(2)   ), gPLOT(lSEED)(lYEAR)(0))    
     gPLOT(lSEED)(lYEAR)(i)(0) = (Cos(Path_theta) * ((gRings – i) /gRings) * temp_Distance) + gPLOT_start(lSEED)(0)
     gPLOT(lSEED)(lYEAR)(i)(1) = (Sin(Path_theta) * ((gRings – i) /gRings) * temp_Distance) + gPLOT_start(lSEED)(1)
    End If
      
     Else ‘ First level… and inner ring
    If lYEAR > gPath_divisions Then
     If i = gRings Then
      gPLOT(lSEED)(lYEAR)(gRings)(0) =  gPLOT_start(lSEED)(0)
      gPLOT(lSEED)(lYEAR)(gRings)(1) =  gPLOT_start(lSEED)(1)
     Else
      gPLOT(lSEED)(lYEAR)(i)(0) = (Cos(Path_theta) * gCent_r) + gPLOT_start(lSEED)(0)
      gPLOT(lSEED)(lYEAR)(i)(1) = (Sin(Path_theta) * gCent_r) + gPLOT_start(lSEED)(1)
     End If     
    Else
     gPLOT(lSEED)(lYEAR)(i)(0) = (Cos(Path_theta) * ((gRings -i) /gRings) * gPath_r) + gPLOT_start(lSEED)(0)
     gPLOT(lSEED)(lYEAR)(i)(1) = (Sin(Path_theta) * ((gRings -i) /gRings) * gPath_r) + gPLOT_start(lSEED)(1)
    End If
   End If
   ‘—————————————————————————-
   If lYEAR > gPATH_divisions + 3 and i = 0 Then
    Call Rhino.AddLine(gPLOT(lSEED)(lYEAR)(i), gPLOT(lSEED)(lYEAR-gPATH_divisions)(i))
   End If
  Next
 Next
  ‘Call Rhino.EnableRedraw(true)
  lYEAR = lYEAR + 1  
 Next

  ‘_______________________ TEMPORARY SCRIPT: VISUALIZATION ____________________________
 
 Dim Temp_arr, Ptemp_i
 Redim Temp_arr(gSEED)
 Redim Ptemp_i(gRINGS-1)

 For lSEED = 0 to gSEED  
  Redim Preserve Temp_arr(lSEED)
  Temp_arr(lSEED) = Ptemp_i
  For lYEAR = 0 to gYEARS
  For i = 0 to (gRINGS-1)
    Temp_arr(lSEED)(i) = Ptemp_y
    Temp_arr(lSEED)(i)(0) = gPLOT(lSEED)(lYEAR)(i)(0)
    Temp_arr(lSEED)(i)(1) = gPLOT(lSEED)(lYEAR)(i)(1)
    Temp_arr(lSEED)(i)(2) = gPLOT(lSEED)(lYEAR)(i)(2)
  Next
  If lYEAR > 1 Then
   sLofter_2 = sLofter_1
   sLofter_1 = Rhino.AddCurve ( Temp_arr(lSEED), 2)
   Call Rhino.AddLoftSrf( array(sLofter_1, sLofter_2) )
  Else
   sLofter_1 = Rhino.AddCurve ( Temp_arr(lSEED), 2)
  End If
  Next
 Next
End Sub

‘################################## YIELD FUNCTION ######################################

Function func_NEAR(lYEAR, lSEED, i, gPLOT, gCHECK)
 Dim tSEED, tYEAR, tI, tCheck, tCheck2, tP
 Redim tP(2)
 tCheck2 = 1000000
 If lYEAR > 1 Then
  For tSEED = (lSEED+1) to gSEED
   For tYEAR = 0 to lYEAR
    If tSEED > lSEED And tYEAR = lYEAR Then
    
    Else
     tCheck = Rhino.distance(    gPLOT(lSEED)(lYEAR)(0),    gPLOT(tSEED)(tYEAR)(0) )
    End If
    
    If tCheck < gCHECK And tCheck < tCheck2 Then
      tCheck2 = tCheck
      tP(0) = gPLOT(tSEED)(tYEAR)(0)(0)
      tP(1) = gPLOT(tSEED)(tYEAR)(0)(1)
      tP(2) = gPLOT(tSEED)(tYEAR)(0)(2)
    End If
   Next
  Next
  If tCheck2 < 1000000 Then
   gPLOT(lSEED)(lYEAR)(i)(0) = tP(0)
   gPLOT(lSEED)(lYEAR)(i)(1) = tP(1)
   gPLOT(lSEED)(lYEAR)(i)(2) = tP(2)
   Call Rhino.Print( “CONNECTION!” )
  End If
  
 End If
End Function
‘################################## YIELD FUNCTION ######################################
Function func_YIELD(gPLOT_yield, lYEAR, Ptemp_x, Ptemp_y, i, gPLOT_avg, lSEED)
 gPLOT_yield(lSEED)(lYEAR)(i) = ( gPLOT_avg(lYEAR) + Random( 50, -50) ) ‘ *** Local Yield
End Function
‘################################# RANDOM FUNCTION ######################################
Function random(low, up) 
 Randomize
 random = ((up – low)* Rnd()) + low ‘ *** take the difference of range
End Function

Advertisements

One response to “071012_Agritect_v3.1

  1. Pingback: MattPauly_071012 « (n)certainties

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s