parametric lace_heath west

081211_layout_08

081211_layout_04

081211_layout_05

081211_layout_06

081211_layout_07

081211_layout_03

081211_layout_02

081211_layout_09

081211_layout_01

Option Explicit

Call distanceBasedRecursion()
Sub distanceBasedRecursion()

Dim strSrf : strSrf = Rhino.GetObjects (“Select surfaces”,8)
Dim arrPts : arrPts = Rhino.GetObjects (“Select points”,1)
Dim arrParameters : arrParameters = array(“Fall Off Distance from Points”, “Minimum Division Length”, “Maximum Division Length”)
Dim arrValues: arrValues = array(“2”, “2”, “4”)
Dim arrResults : arrResults = Rhino.PropertyListBox(arrParameters, arrValues, “Parameters”, “Distance Based Recursion” )
Dim fallOffDist, minLen, maxLen

If IsArray(arrResults) Then
fallOffDist = FormatNumber(arrResults(0))
fallOffDist = fallOffDist
minLen = FormatNumber(arrResults(1))
minLen = minLen
maxLen = FormatNumber(arrResults(2))
maxLen = maxLen
End If

Dim triangle
Call Rhino.Command (“selsrf “)
Dim arrTriangle : arrTriangle = Rhino.SelectedObjects
Rhino.EnableRedraw False
For Each triangle In arrTriangle
subdivideTriangle triangle
Next
Rhino.EnableRedraw True
End Sub

Function subdivideTriangle(triangle)
Dim triangleLength, vertexPts, centerPt, triangleCrv, srfParam, srfNormal, arrTri, nMin, nMax, i, j
arrTri = Rhino.DuplicateSurfaceBorder (triangle)

For Each triangleCrv In arrTri
triangleLength = Rhino.CurveLength(triangleCrv)

For i=0 To UBound(arrTri)
If (triangleLength > 1.5) Then

centerPt = Rhino.CurveAreaCentroid(triangleCrv)
srfParam = Rhino.SurfaceClosestPoint(triangle, centerPt(0))
srfNormal = Rhino.SurfaceNormal(triangle, srfParam)
vertexPts = Rhino.PolylineVertices(triangleCrv)

Dim midpt0, midpt1, midpt2, midpt3, midpt4, midmid3, midmid4, quarterPt0, quarterPt1, quarterPt2, quarterPt3, quarterPt4
Dim triangle0, triangle1, triangle2, triangle3, triangle4, triangle5, triangle6, triangle7

midPt0 = Array(((vertexPts(1)(0) + vertexPts(0)(0)))/2, ((vertexPts(1)(1) + vertexPts(0)(1)))/2, ((vertexPts(1)(2) + vertexPts(0)(2)))/2)
midPt1 = Array(((vertexPts(2)(0) + vertexPts(1)(0)))/2, ((vertexPts(2)(1) + vertexPts(1)(1)))/2, ((vertexPts(2)(2) + vertexPts(1)(2)))/2)
midPt2 = Array(((vertexPts(0)(0) + vertexPts(2)(0)))/2, ((vertexPts(0)(1) + vertexPts(2)(1)))/2, ((vertexPts(0)(2) + vertexPts(2)(2)))/2)
‘midPt3 = Array((vertexPts(3) (0) + vertexPts(4) (0))/2,(vertexPts(3) (1) + vertexPts(4) (1))/2, (vertexPts(3) (2) + vertexPts (4) (2))/2)
‘midPt4 = Array((vertexPts(4) (0) + vertexPts(0) (0))/2,(vertexPts(4) (1) + vertexPts(0) (1))/2, (vertexPts(4) (2) + vertexPts (0) (2))/2)

quarterPt0= Array((midPt0(0) + centerPt(0)(0))/2, (midPt0(1) + centerPt(0)(1))/2, (midPt0(2) + centerPt(0)(2))/2)
quarterPt1= Array((midPt1(0) + centerPt(0)(0))/2, (midPt1(1) + centerPt(0)(1))/2, (midPt1(2) + centerPt(0)(2))/2)
quarterPt2= Array((midPt2(0) + centerPt(0)(0))/2, (midPt2(1) + centerPt(0)(1))/2, (midPt2(2) + centerPt(0)(2))/2)
‘quarterPt3= Array((midPt3(0) + centerPt(0)(0))/2, (midPt3(1) + centerPt(0)(1))/2, (midPt3(2) + centerPt(0)(2))/2)
‘quarterPt4= Array((midPt4(0) + centerPt(0)(0))/2, (midPt4(1) + centerPt(0)(1))/2, (midPt4(2) + centerPt(0)(2))/2)

triangle4 = Rhino.AddSrfPt(Array(vertexPts(0), quarterPt0, quarterPt2))
triangle5 = Rhino.AddSrfPt(Array(vertexPts(1), quarterPt1, quarterPt0))
triangle6 = Rhino.AddSrfPt(Array(vertexPts(2), quarterPt2, quarterPt1))
‘triangle7 = Rhino.AddSrfPt(Array(quarterPt0, quarterPt1, quarterPt2, quarterPt0))

subdivideTriangle triangle4
subdivideTriangle triangle5
subdivideTriangle triangle6
‘subdivideTriangle triangle7’comment out this line to produce a sierpiński triangle

Rhino.DeleteObjects(Array(triangle, triangleCrv))
End If
Next

For j=0 To UBound(arrTri)
If (triangleLength > 3) Then

midPt0 = Array((vertexPts(0) (0) + vertexPts(1) (0))/2,(vertexPts(0) (1) + vertexPts(1) (1))/2, (vertexPts(0) (2) + vertexPts (1) (2))/2)
midPt1 = Array((vertexPts(1) (0) + vertexPts(2) (0))/2,(vertexPts(1) (1) + vertexPts(2) (1))/2, (vertexPts(1) (2) + vertexPts (2) (2))/2)
midPt2 = Array((vertexPts(2) (0) + vertexPts(3) (0))/2,(vertexPts(2) (1) + vertexPts(3) (1))/2, (vertexPts(2) (2) + vertexPts (3) (2))/2)
‘midPt3 = Array((vertexPts(3) (0) + vertexPts(4) (0))/2,(vertexPts(3) (1) + vertexPts(4) (1))/2, (vertexPts(3) (2) + vertexPts (4) (2))/2)
‘midPt4 = Array((vertexPts(4) (0) + vertexPts(0) (0))/2,(vertexPts(4) (1) + vertexPts(0) (1))/2, (vertexPts(4) (2) + vertexPts (0) (2))/2)

triangle0 = Rhino.AddSrfPt(Array(vertexPts(0), midPt0, midPt2))
triangle1 = Rhino.AddSrfPt(Array(vertexPts(1), midPt1, midPt0))
triangle2 = Rhino.AddSrfPt(Array(vertexPts(2), midPt2, midPt1))
triangle3 = Rhino.AddSrfPt(Array(midPt0, midPt1, midPt2, midPt0))

subdivideTriangle triangle0
subdivideTriangle triangle1
subdivideTriangle triangle2
subdivideTriangle triangle3’comment out this line to produce a sierpiński triangle

Rhino.DeleteObjects(Array(triangle, triangleCrv))
End If
Next
Next
End Function

Function RandomNumber(nMin, nMax)
RandomNumber = Null

If Not IsNumeric(nMin) Then Exit Function
If Not IsNumeric(nMax) Then Exit Function

If nMin >= nMax Then Exit Function
Randomize

RandomNumber = Int((nMax – nMin + 1) * Rnd + nMin)
End Function

Advertisements

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