Tuesday, February 5, 2008

Something Flowerly













Recent progress in rvb. As it's explained in script,

1. create sphere in spiral, and scale accordingly
2. draw 2d line, rotate, and move
3. rotate sphere in 3D

thats all. Enjoy.





Option Explicit

addVector()
Sub addVector()

Dim arrCoordinate(2), arrPoint(), arrSphere(), arrScaleSphere()
Dim arrLine(), arrSt(2), arrEd(2), arrRotateLine(), dblAngle
Dim arrFinSphere(), arrAxis(), arrLineEd()
Dim i, t, pi, arrScale
Dim A, B, C
i = 0
dblAngle = 30

For t = -5 To 6 Step 0.05

'create sphere in spiral, and scale accordingly ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
A = 1
B = 1
C = t+5
arrScale = Array(A, B, C)

arrCoordinate(0) = t*Sin(5*t)
arrCoordinate(1) = t*Cos(5*t)
arrCoordinate(2) = t

'ReDim Preserve arrPoint(i)
'arrPoint(i) = Rhino.AddPoint(arrCoordinate) 'don't need a string of point to draw a sphere

ReDim Preserve arrSphere(i)
arrSphere(i) = Rhino.AddSphere(arrCoordinate, 0.25)

ReDim Preserve arrScaleSphere(i)
arrScaleSphere(i) = Rhino.ScaleObject(arrSphere(i), arrCoordinate, arrScale)


'draw 2d line, rotate, and move ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
arrSt(0) = arrCoordinate(0)
arrSt(1) = arrCoordinate(1)
arrSt(2) = 0
arrEd(0) = 0
arrEd(1) = 0
arrEd(2) = 0

ReDim Preserve arrLine(i)
arrLine(i) = Rhino.AddLine(arrSt, arrEd)

ReDim Preserve arrRotateLine(i)
arrRotateLine(i) = Rhino.RotateObject(arrLine(i), arrSt, 90)

Call Rhino.MoveObject (arrLine(i), arrSt, arrCoordinate)


'rotate sphere in 3d '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
ReDim Preserve arrLineEd(i)
arrLineEd(i) = Rhino.CurveEndPoint (arrLine(i))

ReDim Preserve arrAxis(i)
arrAxis(i)= Rhino.VectorCreate (arrCoordinate, arrLineEd(i))

ReDim Preserve arrFinSphere(i)
arrFinSphere(i) = Rhino.RotateObject (arrScaleSphere(i), arrCoordinate, dblAngle, arrAxis(i))

i = i+1
Next

End Sub