(n)certainties – Columbia – Fall 09

(n)certainties – Columbia – Fall 09 header image 3

PROTOCOLS

KYRIAKOS KYRIAKO & ERIC TSE_script

BOXES

Option Explicit
‘Script written by <Eric Tse>
‘Script copyrighted by <Eric Tse>
‘Script version Monday, October 19, 2009 9:11:38 PM
Dim numSegments : numSegments = 20
Dim segmentL : segmentL = 1.25
Dim numPts : numPts = 6
Dim fractScale : fractScale = 0.75
Dim fractNum : fractNum = 1
Dim boxScale : boxScale = 0.25
Dim fractalLim : fractalLim = 0.002
Call Main()
Sub Main()
Dim strBox
Dim arrCrv : arrCrv = rhino.GetObjects (“selcrv”,4)
Dim arrCentroidNew
Dim crv, divpts
Dim i,j,k,l,m
Dim pt, clpt,clparam
ReDim arrpt(pt)
Dim ptparam,plane
Dim xvect,yvect,vect,zvect
Dim Tvect, Tv, Zv, tangVect
Dim Nvect : Nvect = array (0,1,0)
Dim angle
Dim newBox, xBox, arrBox
Dim scale
Dim vScale
Dim fractal_output, vol
rhino.EnableRedraw False
For l = 0 To ubound (arrCrv)
crv = arrCrv(l)
divpts = rhino.DivideCurveLength (crv,segmentL*boxScale)
For i = 0 To ubound(divpts)
ptparam = rhino.CurveClosestPoint (crv,divpts(i))
plane = rhino.CurvePerpFrame (crv,ptparam)
For j = 0 To numPts
xvect = rhino.Vectorrotate (plane(1),fx_Random (0, 360),plane(3))
yvect = rhino.Vectorrotate (plane(1),fx_Random (0, 360),plane(3))
zvect = rhino.VectorScale (plane(3),fx_Random (-0.15, 0.15))
vect = rhino.VectorAdd (xvect,yvect)
vect = rhino.VectorAdd (vect,zvect)
vect = rhino.VectorScale(vect,boxScale)
vect = rhino.vectorscale (vect,fx_Random (0.5,0.75))
pt = rhino.PointAdd (divpts(i),vect)
newBox = Rhino.InsertBlock (“box2″, pt)
newBox = rhino.ScaleObject(newBox,pt,array(boxScale,boxScale,boxScale))
‘find closest point on curve’
clparam = Rhino.CurveClosestPoint (crv, pt)
clpt = rhino.EvaluateCurve (crv,clparam)
‘create vector’
Tvect = Rhino.VectorCreate (pt, clpt)
angle = 45
tangVect = rhino.CurveTangent(crv,clparam)
tangVect = rhino.VectorUnitize(tangVect)
tangVect = rhino.VectorScale(tangVect,1)
Tv = rhino.VectorUnitize (Tvect)
Tv = Rhino.VectorAdd (Tv,tangVect)
Tv = rhino.VectorUnitize (Tv)
Tv = rhino.VectorScale(Tv,boxScale)
scale = 1 * (numPts-(j/2))/numPts
newBox = rhino.ScaleObject(newBox,pt,array(scale,scale,scale))
‘ For m = 0 To fractNum
‘ fractal_output = fractal (newBox,Tv,pt)
‘ newBox = fractal_output(0)
‘ Tv = fractal_output(1)
‘ pt = fractal_output(2)
‘ vol = fractal_output(3)
‘ Next
arrBox = rhino.ExplodeBlockInstance(newBox)
xBox = arrBox(0)
vol = 1000
Do
fractal_output = fractal (xBox,Tv,pt)
xBox = fractal_output(0)
Tv = fractal_output(1)
pt = fractal_output(2)
vol = fractal_output(3)
Loop While vol > fractalLim
Next
Next
Next
rhino.EnableRedraw True
End Sub
Function fractal (xBox,Tv,cntr)
Dim i
Dim box, boxLength, newPt, arrVol, vol
boxLength = 1
box = rhino.CopyObject(xBox)
box = rhino.MoveObject(box,Tv)
newPt = rhino.PointAdd(cntr,Tv)
box = rhino.ScaleObject (box,newPt,array(fractScale,fractScale,fractScale))
Tv = rhino.VectorScale (Tv,fractScale)
arrVol = rhino.MeshVolume(box)
vol = arrVol(1)
fractal = array(box,Tv,newPt,vol)
End Function
Function fx_Random (min, max)
fx_Random = Rnd*(max-min) + min
End Function

Option Explicit’Script written by <Eric Tse>’Script copyrighted by <Eric Tse>’Script version Monday, October 19, 2009 9:11:38 PM
Dim numSegments : numSegments = 20Dim segmentL : segmentL = 1.25Dim numPts : numPts = 6Dim fractScale : fractScale = 0.75Dim fractNum : fractNum = 1Dim boxScale : boxScale = 0.25Dim fractalLim : fractalLim = 0.002
Call Main()Sub Main() Dim strBox Dim arrCrv : arrCrv = rhino.GetObjects (“selcrv”,4) Dim arrCentroidNew Dim crv, divpts Dim i,j,k,l,m Dim pt, clpt,clparam ReDim arrpt(pt) Dim ptparam,plane Dim xvect,yvect,vect,zvect Dim Tvect, Tv, Zv, tangVect Dim Nvect : Nvect = array (0,1,0) Dim angle Dim newBox, xBox, arrBox Dim scale Dim vScale Dim fractal_output, vol rhino.EnableRedraw False For l = 0 To ubound (arrCrv) crv = arrCrv(l) divpts = rhino.DivideCurveLength (crv,segmentL*boxScale) For i = 0 To ubound(divpts) ptparam = rhino.CurveClosestPoint (crv,divpts(i)) plane = rhino.CurvePerpFrame (crv,ptparam) For j = 0 To numPts xvect = rhino.Vectorrotate (plane(1),fx_Random (0, 360),plane(3)) yvect = rhino.Vectorrotate (plane(1),fx_Random (0, 360),plane(3)) zvect = rhino.VectorScale (plane(3),fx_Random (-0.15, 0.15)) vect = rhino.VectorAdd (xvect,yvect) vect = rhino.VectorAdd (vect,zvect) vect = rhino.VectorScale(vect,boxScale) vect = rhino.vectorscale (vect,fx_Random (0.5,0.75)) pt = rhino.PointAdd (divpts(i),vect) newBox = Rhino.InsertBlock (“box2″, pt) newBox = rhino.ScaleObject(newBox,pt,array(boxScale,boxScale,boxScale)) ‘find closest point on curve’ clparam = Rhino.CurveClosestPoint (crv, pt) clpt = rhino.EvaluateCurve (crv,clparam) ‘create vector’ Tvect = Rhino.VectorCreate (pt, clpt) angle = 45 tangVect = rhino.CurveTangent(crv,clparam) tangVect = rhino.VectorUnitize(tangVect) tangVect = rhino.VectorScale(tangVect,1) Tv = rhino.VectorUnitize (Tvect) Tv = Rhino.VectorAdd (Tv,tangVect) Tv = rhino.VectorUnitize (Tv) Tv = rhino.VectorScale(Tv,boxScale) scale = 1 * (numPts-(j/2))/numPts  newBox = rhino.ScaleObject(newBox,pt,array(scale,scale,scale)) ‘ For m = 0 To fractNum ‘ fractal_output = fractal (newBox,Tv,pt) ‘ newBox = fractal_output(0) ‘ Tv = fractal_output(1) ‘ pt = fractal_output(2) ‘ vol = fractal_output(3) ‘ Next arrBox = rhino.ExplodeBlockInstance(newBox) xBox = arrBox(0) vol = 1000  Do fractal_output = fractal (xBox,Tv,pt) xBox = fractal_output(0) Tv = fractal_output(1) pt = fractal_output(2) vol = fractal_output(3) Loop While vol > fractalLim Next Next Next
rhino.EnableRedraw True End Sub
Function fractal (xBox,Tv,cntr)
Dim i Dim box, boxLength, newPt, arrVol, vol boxLength = 1 box = rhino.CopyObject(xBox) box = rhino.MoveObject(box,Tv) newPt = rhino.PointAdd(cntr,Tv) box = rhino.ScaleObject (box,newPt,array(fractScale,fractScale,fractScale)) Tv = rhino.VectorScale (Tv,fractScale) arrVol = rhino.MeshVolume(box) vol = arrVol(1) fractal = array(box,Tv,newPt,vol) End Function
Function fx_Random (min, max) fx_Random = Rnd*(max-min) + min End Function

FIELD

Option Explicit

‘Script written by <insert name>

‘Script copyrighted by <insert company name>

‘Script version Friday, November 20, 2009 2:17:02 PM

Dim range1 : range1 = 16

Dim scale1 : scale1 = 50

Dim range2 : range2 = range1*2

Dim scale2 : scale2 = 75

Dim range3 : range3 = range1*3

Dim arcAngle : arcAngle = 90

Dim arcAngle2 : arcAngle2 = 180

Dim arcArrAngle : arcArrAngle = 5

Dim dblPavilion : dblPavilion = 1.5

Dim dblEnd : dblEnd = 2

Call Main()

Sub Main()

Dim i, j

Dim arrStartPt : arrStartPt = rhino.GetPointCoordinates(“pick start pt”)

Dim arrEndPt : arrEndPt = rhino.GetPointCoordinates(“pick end pt”)

Dim arrPts : arrPts = rhino.GetPointCoordinates(“pick pts”)

Dim arrPtsN

rhino.EnableRedraw(False)

For i = 0 To UBound(arrPts)

arrPtsN = fx_findNeighborsWithinRange(i, arrPts, range1, arrStartPt(0), arrEndPt(0))

If Not isnull(arrPtsN) Then

‘Call rhino.addcircle(rhino.Moveplane(WorldXYPlane,arrPts(i)), range1)

End If

Next

rhino.Command “seldup” & ” ” & “delete”

rhino.LayerVisible “arcs array1″,False

rhino.LayerVisible “arcs array2″,False

rhino.CurrentLayer(“Default”)

rhino.EnableRedraw(True)

End Sub

Function fx_findNeighborsWithinRange(index, arrPts, range1, startPt, endPt)

fx_findNeighborsWithinRange = Null

Dim i, dblDist, n

Dim endVect, newVect, length

Dim arrPtsCollect()

Dim currentPt, newPt, drawPt, vect1, vect2

currentPt = arrPts(index)

If rhino.distance(currentPt,endPt) > 0 Then

Call fx_EndDirection(currentPt,endPt)

End If

endVect = rhino.VectorCreate(startPt,endPt)

n = 0

For i = 0 To Ubound(arrPts)

If i <> index Then

newPt = arrPts(i)

dblDist = rhino.Distance(currentPt,newPt)

newVect = rhino.VectorCreate(currentPt,newPt)

length = rhino.VectorLength(newVect)

newVect = rhino.VectorUnitize(newVect)

newVect = rhino.VectorDivide(newVect,length)

‘newVect = rhino.VectorScale(newVect,100)

If dblDist <= range1 Then

If fx_AngleDiff(endVect,newVect) < 90 Then

rhino.currentlayer(“vects1″)

newVect = rhino.VectorReverse(newVect)

drawPt = rhino.PointAdd(currentPt,newVect)

‘rhino.AddPoint drawPt

vect1 = rhino.AddLine (currentPt,drawPt)

rhino.ScaleObject vect1,currentPt,array(scale1,scale1,scale1)

Call fx_Arc1(currentPt,newPt,endVect)

Call fx_Pavilion(currentPt,newPt)

End If

End If

If dblDist <= range2 Then

ReDim Preserve arrPtsCollect(n)

arrPtsCollect(n) = newPt

n = n + 1

If fx_AngleDiff(endVect,newVect) < 90 Then

If dblDist > range1 Then

rhino.currentlayer(“vects2″)

newVect = rhino.VectorReverse(newVect)

drawPt = rhino.PointAdd(currentPt,newVect)

‘rhino.AddPoint drawPt

vect2 = rhino.AddLine (currentPt,drawPt)

rhino.ScaleObject vect2,currentPt,array(scale2,scale2,scale2)

End If

Call fx_Arc2(currentPt,newPt,endVect)

End If

End If

End If

Next

For i = 0 To Ubound(arrPtsCollect)

rhino.CurrentLayer(“connections”)

rhino.AddLine currentPt,arrPtsCollect(i)

Next

If n > 0 Then

fx_findNeighborsWithinRange = arrPtsCollect

End If

End Function

Function fx_EndDirection(currentPt,endPt)

Dim vect, drawPt

rhino.CurrentLayer(“end direction”)

vect = rhino.VectorCreate(currentPt,endPt)

vect = rhino.VectorUnitize(vect)

vect = rhino.VectorScale(vect,dblEnd)

vect = rhino.VectorReverse(vect)

drawPt = rhino.PointAdd(currentPt,vect)

rhino.AddLine currentPt,drawPt

End Function

Function fx_Pavilion(currentPt,newPt)

Dim vect, vectL, vectR, drawPt, lineR, lineL

rhino.CurrentLayer(“perp lines”)

vect = rhino.VectorCreate(currentPt,newPt)

vectR = rhino.VectorRotate(vect,90,array(0,0,1))

vectR = rhino.VectorUnitize(vectR)

vectR = rhino.VectorScale(vectR,dblPavilion)

drawPt = rhino.PointAdd(newPt,vectR)

lineR = rhino.AddLine (newPt,drawPt)

vectL = rhino.VectorRotate(vect,-90,array(0,0,1))

vectL = rhino.VectorUnitize(vectL)

vectL = rhino.VectorScale(vectL,dblPavilion)

drawPt = rhino.PointAdd(newPt,vectL)

lineL = rhino.AddLine (newPt,drawPt)

rhino.JoinCurves array(lineR,lineL),True

End Function

Function fx_Arc1(p1, p2, endVect)

Dim i

Dim vectMid, vectDraw, vectL, vectR, ptMid, ptL, ptR, ptDraw

vectMid = rhino.VectorCreate(p1,p2)

vectMid = rhino.VectorReverse(vectMid)

vectMid = rhino.VectorUnitize(vectMid)

vectMid = rhino.VectorScale(vectMid,range1)

rhino.CurrentLayer(“arcs array1″)

For i = 0 To (arcAngle/2)/arcArrAngle – 1

vectDraw = rhino.VectorRotate(vectMid,arcArrAngle*i,array(0,0,1))

ptDraw = rhino.PointAdd(p1,vectDraw)

rhino.AddLine p1,ptDraw

vectDraw = rhino.VectorRotate(vectMid,-arcArrAngle*i,array(0,0,1))

ptDraw = rhino.PointAdd(p1,vectDraw)

rhino.AddLine p1,ptDraw

Next

ptMid = rhino.PointAdd(p1,vectMid)

vectL = rhino.VectorRotate(vectMid,arcAngle/2,array(0,0,1))

ptL = rhino.PointAdd(p1,vectL)

vectR = rhino.VectorRotate(vectMid,-arcAngle/2,array(0,0,1))

ptR = rhino.PointAdd(p1,vectR)

rhino.CurrentLayer(“arcs1″)

rhino.AddLine p1,ptL

rhino.AddLine p1,ptR

rhino.AddArc3Pt ptL,ptR,ptMid

End Function

Function fx_Arc2(p1, p2, endVect)

Dim i

Dim vectPt, vectMid, vectDraw, vectL, vectR, ptMid, ptL, ptR, ptDraw

vectPt = rhino.PointAdd(p1,array(0,1,0))

vectMid = rhino.VectorCreate(p1,p2)

vectMid = endVect

vectMid = rhino.VectorReverse(vectMid)

vectMid = rhino.VectorUnitize(vectMid)

vectMid = rhino.VectorScale(vectMid,range2)

rhino.CurrentLayer(“arcs array2″)

For i = 0 To (arcAngle2/2)/arcArrAngle – 1

vectDraw = rhino.VectorRotate(vectMid,arcArrAngle*i,array(0,0,1))

ptDraw = rhino.PointAdd(p1,vectDraw)

rhino.AddLine p1,ptDraw

vectDraw = rhino.VectorRotate(vectMid,-arcArrAngle*i,array(0,0,1))

ptDraw = rhino.PointAdd(p1,vectDraw)

rhino.AddLine p1,ptDraw

Next

ptMid = rhino.PointAdd(p1,vectMid)

vectL = rhino.VectorRotate(vectMid,arcAngle2/2,array(0,0,1))

ptL = rhino.PointAdd(p1,vectL)

vectR = rhino.VectorRotate(vectMid,-arcAngle2/2,array(0,0,1))

ptR = rhino.PointAdd(p1,vectR)

rhino.CurrentLayer(“arcs2″)

rhino.AddLine p1,ptL

rhino.AddLine p1,ptR

rhino.AddArc3Pt ptL,ptR,ptMid

End Function

Function fx_AngleDiff(v0, v1)

Dim u0  : u0  = Rhino.VectorUnitize(v0)

Dim u1  : u1  = Rhino.VectorUnitize(v1)

Dim dot : dot = Rhino.VectorDotProduct(u0, u1)

‘ domain for inverse cosine is -1 <= x <= 1

If (dot < -1.0) Then

dot = -1.0

ElseIf (dot > 1.0) Then

dot = 1.0

End If

fx_AngleDiff = Rhino.ToDegrees(Rhino.ACos(dot))

End Function

TRSJECTORIES

Option Explicit

‘Script written by <Eric Tse>

‘Script copyrighted by <Eric Tse>

‘Script version Sunday, October 18, 2009 9:00:53 PM

Dim ZvectLim : ZvectLim = 45

Dim ZvectSize : ZvectSize = 1

Dim ZvectRotate : ZvectRotate = 0

Dim dbVectScale : dbVectScale = 0.5

Dim dbScale : dbScale = 0.5

Dim dbRadiusFactor : dbRadiusFactor = 0.25

Dim dbShortenV : dbShortenV = 1

Dim textSize : textSize = 0.15

Dim dotSize : dotSize = 0.05

Dim crossScale : crossScale = 2

Call Main()

Sub Main()

Dim i, j, k

Dim arrSrf : arrSrf = rhino.GetObjects(“Select surfaces”,8)

Dim strBox : strBox = rhino.GetObject(“Select box”,16)

Dim gridPts1 : gridPts1 = 3

Dim gridPts2 : gridPts2 = 2

Dim numSegments : numSegments = 4

Dim angleLim : angleLim = 15

Dim numPts1 : numPts1 = 30

Dim numPts2 : numPts2 = 30

Dim dbRadius : dbRadius = 0.35

rhino.HideObject strBox

Dim startPt, newVect, Zvect, ZvectPt, ZvectLine

Dim fx_SrfPts_output, arrStartPts, arrNvects, arrSrfs

Dim fx_Segment_output

Dim arrArrPts()

ReDim arrArrPts(0)

Dim arrArrVects()

ReDim arrArrVects(0)

Dim arrSegments()

ReDim arrSegments(0)

Dim arrRadius()

ReDim arrRadius(0)

Dim fx_IPOC_output

Dim startRadius

Dim blnZvect, ZvectPt1, ZvectPt2, plane, newText

blnZvect = rhino.GetInteger(“Zvect down (0) or choose Zvect (1)”,0,0,1)

If blnZvect = 0 Then

Zvect = array(0,0,-ZvectSize)

Else

ZvectPt1 = rhino.GetPoint(“Select start point for Zvect”)

ZvectPt2 = rhino.GetPoint(“Select end point for Zvect”)

Zvect = rhino.VectorCreate(ZvectPt1,ZvectPt2)

Zvect = rhino.VectorUnitize(Zvect)

Zvect = rhino.VectorReverse(Zvect)

Zvect = rhino.VectorScale(Zvect,ZvectSize)

End If

rhino.EnableRedraw False

‘for each selected surface,

‘divide surface into grid of points

fx_SrfPts_output = fx_SrfPts(arrSrf, gridPts1, gridPts2)

arrStartPts = fx_SrfPts_output(0) ‘array of grid points for each srf

arrNvects = fx_SrfPts_output(1) ‘nvect for each srf

For i = 0 To 0′Ubound(arrSrf) ‘for each surface

For j = 0 To 0′Ubound(arrStartPts(i)) ‘for each start point

ReDim arrArrPts(0)

ReDim arrArrVects(0)

ReDim arrSegments(0)

startPt = arrStartPts(i)(j)

newVect = arrNvects(i)

‘Zvect = array(0,0,-ZvectSize)

startRadius = dbRadius

For k = 0 To numSegments ‘draw number of segments

rhino.CurrentLayer(“text gen”)

plane = rhino.MovePlane(WorldXYPlane,startPt)

newText = rhino.AddText(”   t=” & j+1 & “_” & k+1,plane,textSize)

Call fx_TextCoords(startPt)

fx_Segment_output = fx_Segment(startPt,newVect,Zvect,startRadius,angleLim,numPts1,numPts2,strBox,arrSrf,arrNvects)

arrArrPts(k) = fx_Segment_Output(0)

arrArrVects(k) = fx_Segment_Output(1)

arrSegments(k) = fx_Segment_Output(2)

arrRadius(k) = fx_Segment_Output(3)

fx_IPOC_output = fx_IPOC (arrArrPts,arrArrVects,arrSegments,Zvect, arrRadius)

startPt = fx_IPOC_output(0)

newVect = fx_IPOC_output(1)

startRadius = fx_IPOC_output(2)

If k < numSegments Then

ReDim Preserve arrArrPts(Ubound(arrArrPts)+1)

ReDim Preserve arrArrVects(Ubound(arrArrVects)+1)

ReDim Preserve arrSegments(Ubound(arrSegments)+1)

ReDim Preserve arrRadius(Ubound(arrRadius)+1)

End If

rhino.Command “selall ” & “group”

Next

Next

Next

rhino.EnableRedraw True

rhino.CurrentLayer(“Default”)

End Sub

Function fx_Segment (startPt, newVect, Zvect, startRadius, angleLim, numPts1, numPts2, strBox, arrSrf, arrNvects)

Dim i, j

Dim numPts : numPts = Int(fx_Random(numPts1,numPts2))

Dim arrPts()

ReDim arrPts(numPts)

Dim arrVects()

ReDim arrVects(numPts)

Dim angleDiff, EndPt, strCurve, scaleVect

Dim tempSrf, closestSrf, tempNvect, Nvect, minDist, tempDist, srfCentroid, srfOrigin, tempArr

Dim strPt, arrPtCoord, lowerLim, upperLim

Dim arrRadius()

ReDim arrRadius(numPts)

Dim arrCircles()

ReDim arrCircles(numPts)

Dim plane1, plane2, planeZvect, planePt, planeAngleX, planeAngleY, plane, length, newText

newVect = rhino.VectorScale(newVect,dbShortenV)

arrPts(0) = startPt

arrVects(0) = newVect

plane1 = rhino.PlaneFromNormal(startPt,newVect)

arrRadius(0) = startRadius

rhino.CurrentLayer(“circles”)

arrCircles(0) = Rhino.AddCircle(plane1,startRadius)

rhino.CurrentLayer(“branch pts”)

rhino.AddCircle rhino.Moveplane(WorldXYPlane,startPt),dotSize*1.5

rhino.CurrentLayer(“branch cross”)

rhino.InsertBlock “cross”,startPt,array(crossScale*1.5,crossScale*1.5,crossScale*1.5)

For i = 1 To numPts

scaleVect = rhino.VectorScale(newVect,fx_Random(1-dbVectScale,1+dbVectScale))

EndPt = Rhino.PointAdd(startPt,scaleVect)

If Rhino.IsPointInSurface(strBox,EndPt) Then

arrPts(i) = EndPt

Else

minDist = 100000

For j = 0 To Ubound(arrSrf)

tempSrf = arrSrf(j)

tempNvect = arrNvects(j)

srfCentroid = Rhino.SurfaceAreaCentroid(tempSrf)

srfOrigin = srfCentroid(0)

tempDist = rhino.Distance(EndPt,srfOrigin)

If tempDist < minDist Then

minDist = tempDist

closestSrf = tempSrf

Nvect = tempNvect

End If

Next

tempArr = Rhino.ProjectPointToSurface(EndPt, closestSrf, Nvect)

If Not IsNull(tempArr) Then

EndPt = tempArr(0)

Else

EndPt = arrPts(i – 1)

End If

arrPts(i) = EndPt

End If

arrVects(i) = scaleVect

startPt = EndPt

lowerLim = -angleLim

upperLim = angleLim

newVect = fx_RotateVect(newVect,lowerLim,upperLim,startPt,Zvect)

plane2 = rhino.PlaneFromNormal(startPt,newVect)

planeZvect = plane2(3)

planeAngleX = fx_AngleDiff(plane2(1),plane1(1))

If planeAngleX > 90 Then

plane2 = rhino.RotatePlane(plane2,planeAngleX,planeZvect)

End If

startRadius = startRadius * ((numPts-i/4+1)/numPts) ‘((numPts-(i/dbRadiusFactor)+1)/(numPts))

startRadius = startRadius * (1 + fx_Random(-dbRadiusFactor,dbRadiusFactor))

arrRadius(i) = startRadius

rhino.CurrentLayer(“circles”)

arrCircles(i) = Rhino.AddCircle(plane2,arrRadius(i))

rhino.CurrentLayer(“points”)

rhino.AddCircle rhino.Moveplane(WorldXYPlane,startPt),dotSize

rhino.CurrentLayer(“branch cross”)

rhino.InsertBlock “cross”,startPt,array(crossScale,crossScale,crossScale)

plane1 = plane2

Next

rhino.CurrentLayer(“lofts”)

Rhino.AddLoftSrf arrCircles

rhino.CurrentLayer(“segments”)

strCurve = rhino.AddInterpCurve(arrPts)

rhino.CurrentLayer(“text length”)

length = rhino.CurveLength(strCurve)

plane = rhino.MovePlane(WorldXYPlane,startPt)

rhino.AddText ”   l=” & Int(length),plane,textSize

Call fx_TextCoords(startpt)

fx_Segment = array (arrPts, arrVects, strCurve, arrRadius)

End Function

Function fx_IPOC (arrArrPts, arrArrVects, arrSegments, Zvect, arrRadius)

Dim i, j, k

Dim strLine, arrPt, ptVect

Dim smallestAngle, angleDiff

Dim arrFork()

ReDim arrFork(0)

Dim startPt, newVect, tempPt, tempVect, startRadius

For i = 0 To Ubound(arrArrPts) ‘for each array of pts per segment

For j = 1 To Ubound(arrArrPts(i)) ‘FOR EACH PT IN ARRAY

arrPt = arrArrPts(i)(j)

ptVect = arrArrVects(i)(j)

startPt = arrPt

newVect = ptVect

startRadius = arrRadius(i)(j)

‘rhino.addpoint arrPt

‘check if pt on multiple curves

For k = 0 To Ubound(arrSegments) ‘for each segment

If k <> i Then ‘if segment different from set of pts

strLine = arrSegments(k)

smallestAngle = fx_AngleDiff(ptVect,Zvect)

If Rhino.IsPointOnCurve(strLine, arrPt) Then ‘if pt on segment

tempPt = arrArrPts(k)(j)

tempVect = arrArrVects(k)(j)

angleDiff = fx_AngleDiff(tempVect,Zvect)

If angleDiff < smallestAngle Then ‘find smallest angle

smallestAngle = angleDiff

startPt = tempPt

newVect = tempVect

j = Ubound(arrArrPts(i))

End If

End If

End If

Next

‘check if angleDiff > ZvectLim

angleDiff = fx_AngleDiff(newVect,Zvect)

If angleDiff > ZvectLim/2 Then

‘Rhino.AddPoint startPt

newVect = rhino.VectorAdd(newVect, Zvect)

newVect = rhino.VectorDivide(newVect, 2)

i = Ubound(arrArrPts)

j = Ubound(arrArrPts(i))

End If

Next

Next

fx_IPOC = array(startPt, newVect, startRadius)

End Function

Function fx_SrfPts (arrSrf, gridPts1, gridPts2)

Dim i

Dim num : num = Ubound(arrSrf)

Dim Udom, Vdom

Dim srfCentroid, srfOrigin, scaleSrf

Dim arrPts()

ReDim arrPts(num)

Dim Nvect()

ReDim Nvect(num)

For i = 0 To Ubound(arrSrf)

Udom = rhino.SurfaceDomain (arrSrf(i),0)

Vdom = rhino.SurfaceDomain (arrSrf(i),1)

srfCentroid = Rhino.SurfaceAreaCentroid(arrSrf(i))

srfOrigin = srfCentroid(0)

scaleSrf = Rhino.ScaleObject (arrSrf(i), srfOrigin, array(dbScale,dbScale,dbScale), True)

Rhino.RebuildSurface scaleSrf, Array(gridPts1,gridPts2), Array(gridPts1,gridPts2)

arrPts(i) = rhino.SurfacePoints (scaleSrf)

Rhino.deleteobject scaleSrf

Nvect(i) = Rhino.SurfaceNormal(arrSrf(i), array(Udom(0),Vdom(0)))

Nvect(i) = rhino.VectorScale(Nvect(i),ZvectSize/2)

Next

fx_SrfPts = array (arrPts, Nvect)

End Function

Function fx_RotateVect (newVect, lowerLim, upperLim, newPt, Zvect)

Dim skewAngle, lowerPt, upperPt, zPt, lowerVect, upperVect, drawPt, tempZvect, tempVect

Dim lowerVectX, upperVectX, lowerVectY, upperVectY, lowerVectZ, upperVectZ, arcZ

Dim angleDiff, endPt, midPt, strArc, arrAngleZ, angleZ, angleZPlane, vectLength, oldVect

oldVect = newVect

skewAngle = fx_Random(lowerLim,upperLim)

newVect = Rhino.VectorRotate(newVect,skewAngle,array(0,1,0))

skewAngle = fx_Random(lowerLim,upperLim)

newVect = Rhino.VectorRotate(newVect,skewAngle,array(1,0,0))

skewAngle = fx_Random(lowerLim,upperLim)

newVect = Rhino.VectorRotate(newVect,skewAngle,array(0,0,1))

rhino.CurrentLayer(“text angle”)

angleDiff = fx_AngleDiff(oldVect,newVect)

rhino.AddText ”   Δtv=” & Int(angleDiff) & “°”,newPt,textSize

lowerVectX = Rhino.VectorRotate(newVect,lowerLim,array(0,1,0))

upperVectX = Rhino.VectorRotate(newVect,upperLim,array(0,1,0))

lowerVectY = Rhino.VectorRotate(newVect,lowerLim,array(1,0,0))

upperVectY = Rhino.VectorRotate(newVect,upperLim,array(1,0,0))

lowerVectZ = Rhino.VectorRotate(newVect,lowerLim,array(0,0,1))

upperVectZ = Rhino.VectorRotate(newVect,upperLim,array(0,0,1))

rhino.CurrentLayer(“rvects”)

lowerVect = rhino.VectorAdd(lowerVectX,lowerVectY)

lowerVect = rhino.VectorDivide(lowerVect,2)

lowerVect = rhino.VectorAdd(lowerVect,lowerVectZ)

lowerVect = rhino.VectorDivide(lowerVect,2)

lowerVect = rhino.VectorScale(lowerVect,2)

lowerPt = rhino.PointAdd(newPt,lowerVect)

rhino.AddLine newPt,lowerPt

upperVect = rhino.VectorAdd(upperVectX,upperVectY)

upperVect = rhino.VectorDivide(upperVect,2)

upperVect = rhino.VectorAdd(upperVect,upperVectZ)

upperVect = rhino.VectorDivide(upperVect,2)

upperVect = rhino.VectorScale(upperVect,2)

upperPt = rhino.PointAdd(newPt,upperVect)

rhino.AddLine newPt,upperPt

rhino.CurrentLayer(“zvects”)

vectLength = rhino.VectorLength(newVect)

tempZvect = rhino.VectorScale(Zvect,1)

tempZvect = rhino.VectorUnitize(tempZvect)

tempZvect = rhino.VectorScale(tempZvect,vectLength*2)

zPt = rhino.PointAdd(newPt,tempZvect)

rhino.AddLine newPt,zPt

rhino.CurrentLayer(“arcs”)

tempVect = rhino.VectorScale(newVect,2)

endPt = rhino.PointAdd(newPt,tempVect)

‘rhino.AddPoint midPt

strArc = rhino.AddArc3Pt (lowerPt,upperPt,endPt)

If rhino.ArcAngle(strArc) > 90 Then

rhino.DeleteObject(strArc)

strArc = rhino.AddArc3Pt (upperPt,lowerPt,endPt)

End If

rhino.CurrentLayer(“z arcs”)

angleZPlane = rhino.PlaneFromPoints(newPt,endPt,zPt)

vectLength = rhino.VectorLength(tempVect)

arrAngleZ = rhino.Angle2 (array(newPt,endPt),array(newPt,zPt))

arcZ = rhino.AddArc(angleZPlane,vectLength,arrAngleZ(0))

rhino.CurrentLayer(“text”)

angleZ = Int(arrAngleZ(0))

midPt = rhino.ArcMidPoint(arcZ)

rhino.AddText “-zv=” & angleZ & “°”,midPt,textSize

rhino.CurrentLayer(“vects”)

tempVect = rhino.VectorScale(newVect,2)

drawPt = rhino.PointAdd(newPt,tempVect)

rhino.AddLine newPt,drawPt

rhino.CurrentLayer(“tvects”)

angleDiff = fx_AngleDiff(newVect,Zvect)

If angleDiff > ZvectLim Then ‘ZvectLim is global limit on angle diff

‘rhino.addpoint startPt

newVect = rhino.VectorAdd(newVect, Zvect)

newVect = rhino.VectorDivide(newVect, 2)

tempVect = rhino.VectorScale(newVect,1.5)

drawPt = rhino.PointAdd(newPt,tempVect)

rhino.AddLine newPt,drawPt

End If

fx_RotateVect = newVect

End Function

Function fx_TextCoords(pt)

Dim plane, newText

rhino.CurrentLayer(“text coords”)

plane = rhino.MovePlane(WorldXYPlane,array(pt(0),pt(1)-textSize*1.5,pt(2)))

newText = rhino.AddText(”   x=” & Int(pt(0)),plane,textSize)

plane = rhino.MovePlane(WorldXYPlane,array(pt(0),pt(1)-textSize*1.5*2,pt(2)))

newText = rhino.AddText(”   y=” & Int(pt(1)),plane,textSize)

plane = rhino.MovePlane(WorldXYPlane,array(pt(0),pt(1)-textSize*1.5*3,pt(2)))

newText = rhino.AddText(”   Z=” & Int(pt(2)),plane,textSize)

End Function

Function fx_RotateZvect (Zvect, angleLim)

Dim skewAngle

skewAngle = fx_Random(angleLim,angleLim)

Zvect = Rhino.VectorRotate(Zvect,skewAngle,array(0,1,0))

skewAngle = fx_Random(angleLim,angleLim)

Zvect = Rhino.VectorRotate(Zvect,skewAngle,array(1,0,0))

skewAngle = fx_Random(angleLim,angleLim)

Zvect = Rhino.VectorRotate(Zvect,skewAngle,array(0,0,1))

fx_RotateZvect = Zvect

End Function

Function fx_AngleDiff(v0, v1)

Dim u0  : u0  = Rhino.VectorUnitize(v0)

Dim u1  : u1  = Rhino.VectorUnitize(v1)

Dim dot : dot = Rhino.VectorDotProduct(u0, u1)

‘ domain for inverse cosine is -1 <= x <= 1

If (dot < -1.0) Then

dot = -1.0

ElseIf (dot > 1.0) Then

dot = 1.0

End If

fx_AngleDiff = Rhino.ToDegrees(Rhino.ACos(dot))

End Function

Function fx_Random (min, max)

fx_Random = Rnd*(max-min) + min

End Function

NAOMI OCKO & BENJAMIN BEN_script

XPOINT VISUALIZATION

Option Explicit

‘Script written by <David Mans>

‘Script copyrighted by <Neoarchaic Studio>

‘Script version Wednesday, September 16, 2009 4:56:53 PM

Call Main()

Sub Main()

Dim arrPtset, arrMode, arrOrient

arrPtset = Rhino.GetObjects(“Select Points to Visualize”,1,,True,False)

If isNull(arrPtset) Then Exit Sub

arrMode = Rhino.GetString(“Select Visualization Mode”,”Box”,array(“Circle”,”Sphere”,”Cross”,”Coordinate_System”,”Box”))

If isNull(arrMode) Then Exit Sub

arrOrient = Rhino.GetString(“Select Object Orientation”,”World”,array(“World”, “Active”, “Point”, “Camera”))

If isNull(arrOrient) Then Exit Sub

‘Optional Inputs

Dim arrUserPt, dblRadius, arrCS

If arrOrient = “Point” Then

arrUserPt = Rhino.GetPoint(“Select Point to Orient Objects Towards”,array(0,0,0))

ElseIf arrOrient = “Camera” Then

arrUserPt = Rhino.ViewCamera ()

End If

If arrOrient = “World” Then

arrCS = Rhino.GetString(“World Coordinate System”,”XY”,array(“XY”,”YZ”,”ZX”))

End If

dblRadius = Rhino.GetReal(“Radius”,1)

If isNull(dblRadius) Then Exit Sub

‘Evalute for Each Point

Dim i, j, arrPt, arrPln, tpt(), v(2), x, y, z

If arrMode = “Box” Then

ReDim tPt(7)

x = array(1,-1,-1,1,1,-1,-1,1)

y = array(1,1,-1,-1,1,1,-1,-1)

z = array(-1,-1,-1,-1,1,1,1,1)

ElseIf arrMode = “Cross” Then

ReDim tPt(5)

x = array(1,-1,0,0,0,0)

y = array(0,0,1,-1,0,0)

z = array(0,0,0,0,1,-1)

ElseIf arrMode = “Coordinate_System” Then

ReDim tPt(5)

x = array(-1,0,0,0,0,0)

y = array(0,0,-1,0,0,0)

z = array(0,0,0,0,-1,0)

End If

Call Rhino.EnableRedraw(False)

For i = 0 To uBound(arrPtset) Step 1

arrPt = Rhino.PointCoordinates(arrPtset(i))

‘Set up orientation options

If arrOrient = “World” Then

If arrCS = “XY” Then

arrPln = Rhino.MovePlane(Rhino.WorldXYPlane(),arrPt)

ElseIf arrCS = “YZ” Then

arrPln = Rhino.MovePlane(Rhino.WorldYZPlane(),arrPt)

ElseIf arrCS = “ZX” Then

arrPln = Rhino.MovePlane(Rhino.WorldZXPlane(),arrPt)

End If

ElseIf arrOrient = “Active” Then

arrPln = Rhino.ViewCPlane ()

ElseIf arrOrient = “Point” Then

arrPln = Rhino.PlaneFromNormal (arrPt, Rhino.VectorCreate(arrPt,arrUserPt))

ElseIf arrOrient = “Camera” Then

arrPln = Rhino.PlaneFromNormal (arrPt, Rhino.VectorCreate(arrPt,arrUserPt))

End If

‘Execute Visualization Functions/ Geometry

If arrMode = “Circle” Then

Call Rhino.AddCircle(arrPln,dblRadius)

ElseIf arrMode = “Sphere” Then

Call Rhino.AddSphere(arrPt,dblRadius)

ElseIf arrMode = “Box” Then

For j = 0 To 7 Step 1

tPt(j) = evaluatePlane(arrPln,array(dblRadius*x(j),dblRadius*y(j),dblRadius*z(j)))

Next

Call Rhino.AddBox(tPt)

ElseIf arrMode = “Cross” Or arrMode = “Coordinate_System” Then

For j = 0 To 4 Step 2

tPt(j) = evaluatePlane(arrPln,array(dblRadius*x(j),dblRadius*y(j),dblRadius*z(j)))

tPt(j+1) = evaluatePlane(arrPln,array(dblRadius*x(j+1),dblRadius*y(j+1),dblRadius*z(j+1)))

Call Rhino.AddLine(tPt(j),tPt(j+1))

Next

End If

Next

Call Rhino.EnableRedraw(True)

End Sub

Function evaluatePlane(arrPlane, arrPoint)

evaluatePlane = Null

Dim i, arrPt

arrPt = arrPlane(0)

For i = 0 To 2 Step 1

arrPt = Rhino.PointAdd(arrPt,Rhino.VectorScale(Rhino.VectorUnitize(arrPlane(i+1)),arrPoint(i)))

Next

evaluatePlane = arrPt

End Function

SOFIA KRIMIZI & JOHN BECKER_script

FRACTAL BRANCHING

Option Explicit

‘Script written by <insert name>

‘Script copyrighted by <insert company name>

‘Script version Monday, October 12, 2009 3:05:00 PM

Call recursiveBranch()

Sub recursiveBranch()

Dim line, scale,divPts,i,ang,secndDiv,j

line = Rhino.GetObject(“select a starting lines”,4)

divPts=Rhino.DivideCurve (line, 3)

For i=0 To 20

If i Mod 2 = 0 Then

ang = 100

Else

ang = -100

End If

secndDiv = divPts

For j=0 To 10

secndDiv =  secondFactBranch (secndDiv,-ang)

Next

divPts = primerfractalbranching (divPts ,ang)

Next

End Sub

Function Primerfractalbranching (divPts,angle)

Dim vect1, vect2,dist, dist2,newdivs, newnewdivs,endpt, endpt2,crv, crv2

vect1 = rhino.vectorcreate (divpts(2),divpts(3))

vect1 = rhino.VectorRotate (vect1,angle,array(0,0,1))

vect1 = rhino.vectorunitize (vect1)

dist = rhino.Distance (divpts(0),divpts(3))

dist = dist *0.9

vect1 = rhino.VectorScale (vect1, dist)

endpt = rhino.PointAdd (divpts(2),vect1)

crv = rhino.AddLine (divpts(2),endpt)

rhino.ObjectColor crv,rgb(255,0,0)

newdivs = Rhino.DivideCurve (crv, 3)

Primerfractalbranching = newdivs

End Function

Function secondFactBranch (divPts,ang)

Dim vect1,dist,newdivs,endpt,crv

vect1 = rhino.vectorcreate (divpts(2),divpts(3))

vect1 = rhino.VectorRotate (vect1,ang,array(0,0,1))

vect1 = rhino.vectorunitize (vect1)

dist = rhino.Distance (divpts(0),divpts(3))

dist = dist *0.9

vect1 = rhino.VectorScale (vect1, dist)

endpt = rhino.PointAdd (divpts(2),vect1)

crv = rhino.AddLine (divpts(2),endpt)

newdivs = Rhino.DivideCurve (crv, 3)

secondFactBranch  = newdivs

End Function

Function random (min,max)

random=Rnd*(max-min)+min

End Function