Thursday, February 23, 2006

Rh4_LorenzAttractor_v.060221




Option Explicit
Sub LorenzAttractor()

Dim MaxPuntos : MaxPuntos = 100000
Dim arrPt
Dim x,y,z
x = 1 : y = 1 : z = 1
Dim arrPtPrevious : arrPtPrevious = Array(x,y,z)
Dim h : h = 0.001
Dim nPuntos : nPuntos = 0

Do While (nPuntos < MaxPuntos)
x = x + h * dx(x,y,z)
y = y + h * dy(x,y,z)
z = z + h * dz(x,y,z)
arrPt = Array(x,y,z)
'Rhino.addPoint arrPt
Rhino.addLine arrPtPrevious, arrPt
arrPtPrevious = arrPt
nPuntos = nPuntos + 1
Loop

End Sub
LorenzAttractor

Function dx (x,y,z)
dx = 10 * ( y - x )
End Function
Function dy (x,y,z)
dy = -x * z + 28 * x - y
End Function
Function dz (x,y,z)
dz = x * y - ( 8 / 3 ) * z
End Function