Thursday, October 4, 2007

SineWave

Today's Script: Generate a sine wave, create spheres and scale them in order.













Option Explicit
'draw a sine wave using points

SineWave()
Sub SineWave()

Dim x, y, dblA, dblB, arr, dblStep, arrPoint(), arrSphere(), i, A, B, C
dblA = 0
dblB = 12
dblStep = 0.25
i = 0

For x = dblA To dblB Step dblStep
y = 2*Sin(x)

A = 0.02*i
B = 0.02*i
C = 0.03*i
arr = Array(A, B, C)

Call Rhino.AddPoint (Array (x,y,0))
ReDim Preserve arrPoint(i)
arrPoint(i) = Array (x,y,0)

ReDim Preserve arrSphere(i)
arrSphere(i) = Rhino.AddSphere (Array (x,y,0), 0.25)

Call Rhino.ScaleObject (arrSphere(i), arrPoint(i), arr)


Call Rhino.Sleep(30)
i = i+1
Next

End Sub