Kangarooing with Python scripting

Here is an example of Kangarooing with Python scripting.
You need to keep Toggle switch False when editing.
After that, turn on the Toggle switch.
The four input points are the corner points and you can move them by dragging them.

```import rhinoscriptsyntax as rs
import Rhino.Geometry as rg
import random
dt=0.1
gamma=0.98
L=(P-Q).Length
return ((P-Q),(Q-P))
if x:
a=list()
X[0]=rs.PointCoordinates(P3)
X[nV-1]=rs.PointCoordinates(P1)
X[nU*nV-nV]=rs.PointCoordinates(P4)
X[nU*nV-1]=rs.PointCoordinates(P2)
for t in range(10):
for i in range(len(A)):
A[i]=rg.Vector3d(0,0,0)
for i in cbl:
A[0]=rg.Vector3d(0,0,0)
A[nV-1]=rg.Vector3d(0,0,0)
A[nU*nV-nV]=rg.Vector3d(0,0,0)
A[nU*nV-1]=rg.Vector3d(0,0,0)
for i in range(len(A)):
V[i]=gamma*V[i]-A[i]*dt
X[i]+=V[i]*dt
for i in cbl:
else:
nU=10
nV=10
X=list()
V=list()
A=list()
cbl=list()
C=(rs.PointCoordinates(P1)+rs.PointCoordinates(P2)+rs.PointCoordinates(P3)+rs.PointCoordinates(P4))/4
for i in range(nU):
for j in range(nV):
X.append(C+rg.Point3d(random.random()-0.5,random.random()-0.5,random.random()-0.5))
V.append(rg.Vector3d(0,0,0))
A.append(rg.Vector3d(0,0,0))
for i in range(nU):
for j in range(nV-1):
cbl.append((j+i*nV,j+i*nV+1))
for j in range(nV):
for i in range(nU-1):
cbl.append((j+i*nV,j+(i+1)*nV))
```

page revision: 4, last edited: 11 Nov 2013 14:02