' 01/06/16 Lorenz Attractor ' This script draws the Lorenz attractor ' Which plane to draw - if 1,2,3, chosen plane ' is mapped to Rhino's XY plane. ' 0 = draw full 3D curve ' 1 = XY plane ' 2 = YZ plane ' 3 = XZ plane drawPlane=0 ' Timestep and max steps dt=0.01 stepCnt=5000 ' Lorenz parameters (don't change) s=10 r=28 b=2.667 ' Define the point array Dim myPoints ReDim myPoints(stepCnt-1) ' Initialise first point myPoints(0)=Array(0,1,1.05) ' Iterate through points For n=0 To stepCnt-2 ' Calculate derivatives x_dot=s*(myPoints(n)(1)-myPoints(n)(0)) y_dot=(myPoints(n)(0)*(r-myPoints(n)(2)))-myPoints(n)(1) z_dot=(myPoints(n)(0)*myPoints(n)(1))-(b*myPoints(n)(2)) ' Calculate next point myPoints(n+1)=Array(myPoints(n)(0)+(x_dot*dt),myPoints(n)(1)+(y_dot*dt),myPoints(n)(2)+(z_dot*dt)) ' Uncomment this to see the individual points being drawn 'Rhino.addpoint myPoints(n) Next ' Depending on the chosen plane, map coordinates If drawPlane>0 Then ' Go through the points and swap required coordinates ' to map to Rhino XY plane For n=0 To stepCnt-1 ' Map XY points Select Case drawPlane Case 1 ' XY plane: leave XY alone Case 2 ' YZ plane: map Y->X, Z->Y myPoints(n)(0)=myPoints(n)(1) myPoints(n)(1)=myPoints(n)(2) Case 3 ' XZ plane: map X->X, Z->Y myPoints(n)(1)=myPoints(n)(2) Case Else End Select ' Set Z coordinate to zero myPoints(n)(2)=0 Next End If ' Now draw the actual curve Rhino.AddInterpCurve myPoints