3d function plots
[PyX/mjg.git] / gallery / path / springs.py
blob379c7db89d3bf0cbbb925cc040f6f8056cb08c5b
1 # contributed by Gert-Ludwig Ingold
3 from pyx import *
5 n = 3 # number of masses
6 r = 3.0 # system radius
7 rcyc = 0.3 # radius of cycloid
8 nl = 13 # number of loops
9 rc = 0.5 # radius of masses
10 eps = 0.03 # extra spacing for surrounding circles
12 c = canvas.canvas()
13 springcircle = path.circle(0, 0, r)
14 masspositions = [i*springcircle.arclen()/n
15 for i in range(n)]
16 for springsegment in springcircle.split(masspositions):
17 c.stroke(springsegment,
18 [deformer.cycloid(rcyc, nl),
19 deformer.smoothed(radius=0.1)])
20 for x, y in springcircle.at(masspositions):
21 c.fill(path.circle(x, y, rc))
23 c.stroke(springcircle, [deformer.parallel(rc+eps)])
24 c.stroke(springcircle, [deformer.parallel(-rc-eps)])
26 c.writeEPSfile("springs")
27 c.writePDFfile("springs")