(n)certainties – Columbia – Fall 2008

MS_Function.Vault

Function Vault (arrpts, cntr,Factor, switch,iteration)
 Dim a,b, q, r, w, i
 Dim intcnter,arrd(),arrzheight()
 Dim user,winz,winID
 Dim shortD, fctr, addpt, topcnt, zdif, vertcrv, slicepts
 Dim arrcontrolPt(),arrcrvpts(),crvDiv, streamcrv
 Dim NewStreamQ(), NewStreamR(), NewStreamW()
 Dim newcenter, vect, vect2
 Dim dumpQ(),dumpR(),dumpW(), d1, d2, d3, EqScore
 Dim Dcnt, temppt, WiggleVect,rndm,Zvect,plane,xyplane,lay
 intcnter = FindCenter (arrpts)
 newcenter = cntr
 w=0
 q=0
 r=0
 xyplane = Rhino.WorldXYPlane ()
 For a= 0 To Ubound (arrpts)
  lay = Rhino.CurrentLayer ()
  Rhino.AddLayer “Circles”
  Rhino.CurrentLayer “Circles”
  plane = Rhino.MovePlane (xyplane,arrpts(a))
  Rhino.AddCircle plane,2
  Rhino.CurrentLayer lay
  ReDim Preserve arrd(a)
  ReDim Preserve  arrzheight(a)
  arrd(a) = Rhino.Distance (arrpts(a),newcenter)
  arrzheight(a) = arrpts(a)(2)
  If a = 0 Then
   user = arrpts(a)
   winZ= arrzheight(a)
   winID = a
  Else
   If arrzheight(a)>winZ Then
    user = arrpts(a)
    winZ= arrzheight(a)
    winID = a
   End If
  End If
 Next

  
 shortD = Rhino.Min (arrd)
 ’If shortD > lowValt Then
 ’ fctr = DblFctr
 ’ Else

 fctr = Factor

 ’End If
 ’If fctr<4 Then
 ’fctr = 4
 ’End If
 zDif= arrpts(winID)(2) – newcenter(2)
 addpt = array(0,0,shortD*fctr)
 topcnt = Rhino.PointAdd (newcenter, addpt)
 topcnt = Rhino.PointAdd (topcnt, array(0,0,zDif))
 vect = Rhino.VectorCreate (topcnt, intcnter)
 vect = Rhino.VectorScale (vect, 0.67)
 

 vertcrv = Rhino.AddLine (intcnter, topcnt)
 ’slicepts = Rhino.DivideCurveLength (vertcrv, Zstep)
 
 For b = 0 To Ubound (arrpts)
  ReDim Preserve arrcontrolPt(b)
  arrcontrolPt(b) = Rhino.PointAdd (arrpts(b), addpt)

 Next
 If switch <> 0 Then
  EqScore = GetEQScore (arrcontrolPt)
  If EqScore < EQMin*.8 Then
   d1 = Rhino.Distance(arrcontrolPt(0), arrcontrolPt(1))
   d2 = Rhino.Distance(arrcontrolPt(1), arrcontrolPt(2))
   d3 = Rhino.Distance(arrcontrolPt(2), arrcontrolPt(0))
   If d1 > d2 And d1 > d3 Then
    vect2 = Rhino.VectorCreate (arrcontrolPt(2), newcenter)
    vect2 = Rhino.VectorScale (vect2, .4)
    arrcontrolPt(2) = Rhino.PointAdd (arrcontrolPt(2), vect2)
    ’Rhino.AddPoint arrcontrolPt(2)
   End If
   If d2 > d1 And d2 > d3 Then
    vect2 = Rhino.VectorCreate (arrcontrolPt(0), newcenter)
    vect2 = Rhino.VectorScale (vect2, .4)
    arrcontrolPt(0) = Rhino.PointAdd (arrcontrolPt(0), vect2)
    ’Rhino.AddPoint arrcontrolPt(0)
   End If
   If d3 > d2 And d3 > d1 Then
    vect2 = Rhino.VectorCreate (arrcontrolPt(1), newcenter)
    vect2 = Rhino.VectorScale (vect2, .4)
    arrcontrolPt(1) = Rhino.PointAdd (arrcontrolPt(1), vect2)
    ’Rhino.AddPoint arrcontrolPt(1)
   End If
  End If
 End If
 
 For b = 0 To Ubound (arrpts)
  ReDim Preserve arrcrvpts(b)
  ’vect2= Rhino.VectorCreate (arrcontrolPt(b), topcnt)
  ’vect2 = Rhino.VectorScale(vect2, 0.05)
  ’arrcontrolPt(b) = Rhino.PointAdd (arrcontrolPt(b), vect2)
  arrcrvpts(b) = array (arrpts(b), arrcontrolPt(b), topcnt)
  
  streamcrv = Rhino.AddCurve (arrcrvpts(b))
  crvDiv = Rhino.DivideCurveLength (streamcrv, Zstep)
  Rhino.DeleteObject streamcrv
  Select Case b
   Case 0
    ReDim Preserve NewStreamQ(q)
    NewStreamQ(q) = crvDiv
    q=q+1
   Case 1
    ReDim Preserve NewStreamR(r)
    NewStreamR(r) = crvDiv
    r=r+1
   Case 2
    ReDim Preserve NewStreamW(w)
    NewStreamW(w) = crvDiv
    w=w+1
  End Select
 Next
 Rhino.DeleteObject vertcrv
 If switch = 0  Then
  If Ubound (NewStreamQ(0)) > kissingDist Then
   For i=0 To Ubound (NewStreamQ(0))-kissingDist-1
    ReDim Preserve dumpQ(i)
    dumpQ(i)=NewStreamQ(0)(i)
   Next
  Else
   For i=0 To Ubound (NewStreamQ(0))
    ReDim Preserve dumpQ(i)
    dumpQ(i)=NewStreamQ(0)(i)
   Next
  End If
  If Ubound (NewStreamR(0)) > kissingDist Then
   For i=0 To Ubound (NewStreamR(0))-kissingDist-1
    ReDim Preserve dumpR(i)
    dumpR(i)=NewStreamR(0)(i)
   Next
  Else
   For i=0 To Ubound (NewStreamR(0))
    ReDim Preserve dumpR(i)
    dumpR(i)=NewStreamR(0)(i)
   Next
  End If
  If Ubound (NewStreamW(0)) > kissingDist Then
   For i=0 To Ubound (NewStreamW(0))-kissingDist-1
    ReDim Preserve dumpW(i)
    dumpW(i)=NewStreamW(0)(i)
   Next
  Else
   For i=0 To Ubound (NewStreamW(0))
    ReDim Preserve dumpW(i)
    dumpW(i)=NewStreamW(0)(i)
   Next
  End If
 Else
  For i=0 To Ubound (NewStreamQ(0))
   ReDim Preserve dumpQ(i)
   dumpQ(i)=NewStreamQ(0)(i)
  Next
  For i=0 To Ubound (NewStreamR(0))
   ReDim Preserve dumpR(i)
   dumpR(i)=NewStreamR(0)(i)
  Next
  For i=0 To Ubound (NewStreamW(0))
   ReDim Preserve dumpW(i)
   dumpW(i)=NewStreamW(0)(i)
  Next
 End If
 Dcnt = Rhino.PointAdd (topcnt, array(topcnt(0),topcnt(1),-1*topcnt(2)))
 Zvect = Rhino.VectorCreate (array(0,0,0),array(0,0,1))
 
 For i = 0 To Ubound (dumpQ)
  temppt = Rhino.PointAdd (dumpQ(i), array(dumpQ(i)(0),dumpQ(i)(1),-1*dumpQ(i)(2)))
  WiggleVect = Rhino.VectorCreate(temppt,Dcnt)
  WiggleVect = Rhino.VectorUnitize (WiggleVect)
  rndm = random(xywiggle(0),xywiggle(1))
  WiggleVect  = Rhino.VectorScale (WiggleVect, rndm)
  dumpQ(i) = Rhino.PointAdd (dumpQ(i),WiggleVect)
  Zvect = Rhino.VectorUnitize (Zvect)
  Zvect = Rhino.VectorScale (Zvect, random(zwiggle(0),zwiggle(1)))
  dumpQ(i) = Rhino.PointAdd (dumpQ(i),Zvect)
 Next
 
 For i = 0 To Ubound (dumpR)
  temppt = Rhino.PointAdd (dumpR(i), array(dumpR(i)(0),dumpR(i)(1),-1*dumpR(i)(2)))
  WiggleVect = Rhino.VectorCreate(temppt,Dcnt)
  WiggleVect = Rhino.VectorUnitize (WiggleVect)
  rndm = random(xywiggle(0),xywiggle(1))
  WiggleVect  = Rhino.VectorScale (WiggleVect, rndm)
  dumpR(i) = Rhino.PointAdd (dumpR(i),WiggleVect)
  Zvect = Rhino.VectorUnitize (Zvect)
  Zvect = Rhino.VectorScale (Zvect, random(zwiggle(0),zwiggle(1)))
  dumpR(i) = Rhino.PointAdd (dumpR(i),Zvect)
 Next
 
 For i = 0 To Ubound (dumpW)
  temppt = Rhino.PointAdd (dumpW(i), array(dumpW(i)(0),dumpW(i)(1),-1*dumpW(i)(2)))
  WiggleVect = Rhino.VectorCreate(temppt,Dcnt)
  WiggleVect = Rhino.VectorUnitize (WiggleVect)
  rndm = random(xywiggle(0),xywiggle(1))
  WiggleVect  = Rhino.VectorScale (WiggleVect, rndm)
  dumpW(i) = Rhino.PointAdd (dumpW(i),WiggleVect)
  Zvect = Rhino.VectorUnitize (Zvect)
  Zvect = Rhino.VectorScale (Zvect, random(zwiggle(0),zwiggle(1)))
  dumpW(i) = Rhino.PointAdd (dumpW(i),Zvect)
 Next
 
 
 

 Vault = array(dumpQ,dumpR,dumpW)
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