22 May 2009

Simple Spiral script

In page 37 of David Rutten’s RhinoScript101 there’s a PointSpiral script as an example to understand point coordinates as arrays of three numbers, once you’ve got loops and an introduction to arrays. Since I usually have a short period of time to introduce this, I’m used to present a simplified example to address an introduction to both issues, with the argument that in this scripting strategies (constructive geometry methods, and further, generative design); points are, by far, the most representative use of arrays and one of the most common needs for incremental loops in those algorithms.

In the image is also interesting that, since we’re creating separated elements, it seems to be six spirals instead of just one, because distances from points in consecutive iterations are larger than distances from other spins of the spiral. The script goes:

Call SimpleSpiral()
Sub SimpleSpiral()
    Dim Pts(2)
    Dim i
    For i = 0 To 49
        Pts(0) = i * Sin(i)
        Pts(1) = i * Cos(i)
        Pts(2) = 0
        Call Rhino.AddPoint(Pts)
    Next
End Sub

No comments:

Post a Comment