Here is a little script for you to start.
import geompy,random,math
nPts = 240
print "Creating %s points"%nPts
for i in range(nPts):
x = random.random()
y = random.random()
z = random.random()
v = geompy.MakeVertex(x, y, z)
geompy.addToStudy(v, "Vertex_%d"%(i+1) )
print "Done"
print "Creating a spiral"
nbPeriods=2
period=1e-2
t=0
step=period/50
ptList = []
while (t<=2*math.pi*period):
x=math.cos(2*math.pi*t/period)
y=math.sin(2*math.pi*t/period)
z=t*50
t += step
v = geompy.MakeVertex(x, y, z)
geompy.addToStudy(v, "Helix_%f"%t )
ptList.append(v)
polyline = geompy.MakePolyline(ptList)
interpol = geompy.MakeInterpol(ptList)
geompy.addToStudy(polyline, "polyline" )
geompy.addToStudy(interpol, "interpol" )
print "Done"
Here I create 240 points in the for loop. Those are random points but you can use this loop to read a file which contains your points.
Then I calculate the coordinates of points on a helix and I use them to create points. Finally I use those points to create a curve (well 2: a polyline and an interpolate).
Hope this will help you.
No comments:
Post a Comment