Bend by The Experimental Design Lab | ex-lab 2012

Page 170

Exercise Firstly, we set up the inputs for the script component. Use a panel component to define the pattern for the recursion script. Create a slider to define the number of iterations of the function, and a curve component to reference the list of curves to use in the script. Note - the pattern is used to specify which curve to use. For example, 012 will use curve 0, then curve 1, then curve 2, then repeat. For this reason, the pattern cannot specify a curve index that is greater than the number of curves you have referenced.

Next, setup the VB component. Add an input called crvs, change its input to LIST ACCESS and type hint to CURVE. Add an input called iterations, and connect the slider. Add an input called pattern, and connect the panel.

By now our script should be looking a little familiar, as the main body of the script is similar. We create a New list(Of Curve) object called crvList to store our chain of curves, and we add the first referenced curve to the list to begin with. Then we define our variable to keep track of the number of iterations we have performed, and we split our string into an array (sort of like a list) of individual characters (pattern. ToCharArray()) for ease of use in our recursive function. Finally we make the call to our function, and output the result. Now, lets get on to the function code.

‘--------------------------‘Recursive Chain ‘elseware ‘gwyllim jahn ‘copyright 2012 ‘--------------------------‘create an output tree and add our first string Dim crvList As New list(Of Curve) crvList.add(crvs(0)) Dim currentIter As Integer = iterations Dim chars As Array = pattern.ToCharArray() ‘run the recursive function and output ‘the final tree createChain(crvList, crvs, currentIter, chars, iterations) a = crvList

170


Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.