(n)certainties – Columbia – Fall 2007

071003_Agritect_v2.1

Option Explicit

‘_________________________________________________________________________________________

Dim gPath_divisions, gPath_r, gPath_height, gYears, gRings
Dim gPLOT_yield
Dim gPLOT_low, gPLOT_high, Ptemp_x, Ptemp_y
‘#################################### PARAMETERS #########################################

 gPath_divisions = 20  ’ <– Number of Years for one cycle
 gPath_r = 30   ’ <– Radius of entire structure (base radius)
 gRings = 7    ’ <– Number of CONCENTRIC rings from center
 gPath_height = .2   ’ <– HEIGHT OF EACH CHANGE IN ITERATION
 gYEARS = 403    ’ <– NUMBER OF YEARS OF GROWTH
 gPLOT_high = 200   ’ <– Maximum Yield 
 gPLOT_low = 100   ’ <– Minimum Yield

‘#########################################################################################
Call Rhino.Print(“Floor to floor height is ” & (gPath_height * gPath_divisions) )

Redim Ptemp_x(gYears)
Redim Ptemp_x(gRings)

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

‘################################# GROWTH FUNCTION #######################################

Sub Growth(gPath_divisions, gPath_r, gPath_height, gYears, gRings, gPLOT_high, gPLOT_low)

 Dim Path(2), Path_theta, gPLOT(), lYEAR, Ptemp_x(), Ptemp_y(), i, sLofter_1, sLofter_2, gPLOT_yield(), gPLOT_avg()
 Dim lPosition(2), l_m, l_b, l_changex, l_changey, lTemp(2)
 Dim  SURFtemp, Struct_height
 
 Redim Ptemp_x(gRings)
 Redim Ptemp_y(2)
 Redim gPLOT_avg(gYEARS)
 Redim gPLOT_surf(gYEARS)
 lYEAR = 0

 ’____________________________________________________________________________________
 For Path_theta = 0 to (6.28/gPath_divisions * gYEARS) Step (6.28/gPath_divisions)
 ’Call Rhino.EnableRedraw(false)
  Redim Preserve gPLOT(lYEAR)
  gPLOT(lYEAR) = Ptemp_x
  gPLOT_surf(lYEAR) = Ptemp_x
  
  l_changex = 0
  l_changey = 0
  ’————————————————-
  If lYEAR > 2 Then
   gPLOT_avg(lYEAR) = (Random(gPLOT_low, gPLOT_high) +gPLOT_avg(lYEAR-1)+ gPLOT_avg(lYEAR-2)+ gPLOT_avg(lYEAR-3))/4 ‘ *** Field “Average”
  Else
   gPLOT_avg(lYEAR) = Random(gPLOT_low, gPLOT_high)
  End If
  ’_________________________________________________________________________________
  For i = 1 to gRings
   gPLOT(lYEAR)(i) = Ptemp_y
   
   Call func_YIELD(gPLOT_yield, gPLOT_low, gPLOT_high, lYEAR, gRings, Ptemp_x, Ptemp_y, i, gPLOT_avg)
   ’ ——- Z : VERTICAL in relation to YIELD ——   
   If lYEAR = 0 Then
    gPLOT(lYEAR)(i)(2) = 0
   Else
    If lYEAR > gPath_divisions Then
    gPLOT(lYEAR)(i)(2) = ( gPLOT_yield(lYEAR)(i)/((gPLOT_high+gPLOT_low)/2) * gPath_height *gPath_divisions ) + gPLOT(lYEAR-gPath_divisions)(i)(2)
    Else
    gPLOT(lYEAR)(i)(2) = ( gPLOT_yield(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 > 1 Then ‘All levels above first
    lPosition(0) = gPlot(lYEAR – gPATH_divisions)(i)(0)
    lPosition(1) = gPlot(lYEAR – gPATH_divisions)(i)(1)
    lPosition(2) = gPlot(lYEAR – gPATH_divisions)(i)(2) + gPath_height * gPATH_divisions ‘X
    
    l_m = ( lPosition(2) – gPLOT(lYEAR – gPATH_divisions)(i-1)(2) ) / ( lPosition(0) – gPLOT(lYEAR – gPATH_divisions)(i-1)(0) )
    l_b = ( lPosition(2) – l_m * lPosition(0) )
    
    gPlot(lYEAR)(i)(0) = ((gPlot(lYEAR)(i)(2) – l_b)/ l_m ) + l_changex
    
    l_m = ( lPosition(2)-gPLOT(lYEAR-gPATH_divisions)(i-1)(2) )/ ( lPosition(1)-gPLOT(lYEAR-gPATH_divisions)(i-1)(1) )
    l_b = ( lPosition(2) – l_m * lPosition(1) ) 
    
    gPlot(lYEAR)(i)(1) = ((gPlot(lYEAR)(i)(2) – l_b)/ l_m ) + l_changey
    
    l_changex = gPlot(lYEAR)(i)(0) – lPosition(0)
    l_changey = gPlot(lYEAR)(i)(1) – lPosition(1)
    

   Else ‘ First level… and inner ring
    gPLOT(lYEAR)(i)(0) = Cos(Path_theta) * (i /gRings) * gPath_r
    gPLOT(lYEAR)(i)(1) = Sin(Path_theta) * (i /gRings) * gPath_r
    l_changex = 0
    l_changey = 0
   End If
     
   ’######### TEMPORARY SCRIPT: VISUALIZATION #########
   Dim temp_uDomain, temp_vDomain, temp_knot, temp_u, temp_v, temp_point
   If lYEAR > 3 Then
   ’———-
    If i > 1 Then
     If lYEAR > gPATH_divisions + 3 and i = gRings Then
      Call Rhino.AddLine(gPLOT(lYEAR)(i), gPLOT(lYEAR-gPATH_divisions)(i))
     End If
   ’———-
     SURFtemp = Rhino.AddSrfPt (array(gPLOT(lYEAR-3)(i),gPLOT(lYEAR-3)(i-1),gPLOT(lYEAR-4)(i-1),gPLOT(lYEAR-4)(i)    ))

     temp_uDomain = Rhino.SurfaceDomain (SURFtemp, 0)
     temp_vDomain = Rhino.SurfaceDomain (SURFtemp, 1)
     
     temp_u = random(temp_uDomain(0), temp_uDomain(1))
     temp_v = random(temp_vDomain(0), temp_vDomain(1))
          
     Call Rhino.InsertSurfaceKnot (SURFtemp, array(temp_u, temp_v), 2)
     temp_point = Rhino.SurfaceKnots(SURFtemp)
     ’Call Rhino.Print(“(” & temp_point(0)(1) & “, ” & temp_point(1)(1) & “)”)
     ’temp_point = Rhino.SurfaceAreaCentroid (SURFtemp)
     ’If IsArray(temp_point) Then
     ’ Call Rhino.AddPoint(temp_point(0))
     ’End If
    End If
   ’———-    
   End If
   ’###################################################
  Next
  lYEAR = lYEAR + 1  
‘ Call Rhino.EnableRedraw(true)
 Next
End Sub
‘################################## YIELD FUNCTION ######################################
Function func_YIELD(gPLOT_yield, intlow, intup, lYEAR, gRings, Ptemp_x, Ptemp_y, i, gPLOT_avg)
 ’——————————————-
 ReDim Preserve gPLOT_yield(lYEAR)
 gPLOT_yield(lYEAR) = Ptemp_x
 gPLOT_yield(lYEAR)(i) = ( gPLOT_avg(lYEAR) + Random( -5, 5) ) ‘ *** Local Yield
End Function
‘################################# RANDOM FUNCTION ######################################
Function random(low, up) 
 Randomize
 random = ((up – low)* Rnd()) + low ‘ *** take the difference of range
End Function

1 Comment

1 response so far ↓

Leave a Comment