## Monday, April 23, 2012

### Spiral along spiral

import rhinoscriptsyntax as rs
import math
points=[]

n=
10
for i in range(0, n):
x = math.sin(i)
y = math.cos(i)
z = i
pt = rs.
points.append(pt)
crv = rs.AddInterpCurve(points) ## interpolate crv along the list of points

crvDomain = rs.CurveDomain(crv) ## get the domain of curve U value
points = []

m=
100 ## define number of segments for new spiral
for i in range(0,m+1): ## FOR LOOP for 'm' segments, segment for a new spiral
i = ((crvDomain[1]-crvDomain[0])/m)*i ## translate 'm' to curve domain range
uValue = rs.EvaluateCurve(crv,i)
crvF = rs.CurvePerpFrame(crv,i) ## rs.CurvePerpFrame() returns list of [origin,xAxis,yAxis,zAxis]
vect = crvF[2] ## use yAxis of perpendicular frame
vect = rs.VectorScale(vect, 0.1) ## too big? scale it
vect = rs.VectorRotate(vect, 90*(m/n)*i, crvF[3])## rotate according to steps -> get new vector
pt = rs.MoveObject(pt,vect) ## move the pt on the U value based on new vector
points.append(pt)

#### 1 comment:

1. another way to do the same - by moving along the X axis and rotating along the Z axis

steps = 100
stepSize = 1/steps
dist = 0.1
rotation = 30

for t in range(steps+1):
###normalize the curve t parameter to fit different curve length