fix manual build process for sphinx 1.3.1
[PyX.git] / design / selfinter1.py
blob67b59367bd7858a1d3677286dbf5246c8df29de2
1 #!/usr/bin/env python
2 import sys;sys.path.insert(0, "..")
3 from math import *
4 #sys.path.insert(0, os.path.expanduser("~/python/pyx-trunk"))
5 from pyx import *
6 # File for invalid parametrisations of Bezier curves
7 # Some examples
9 def Dx_m(Dy):
10 return (-1-2*Dy-sqrt((1+2*Dy)**2+3))/3.0
12 def Dx_p(Dy):
13 return (-1-2*Dy+sqrt((1+2*Dy)**2+3))/3.0
15 def pass00(Dy):
16 return 1.0/(3.0*(Dy+1))
18 def pass10(Dy):
19 return (1.0+Dy**3)/(3.0*(Dy+1))
21 def acurve(Dx, Dy, trafo_reverse=False):
22 p = path.curve(0,0, 0,1, Dx,1+Dy, 1,0)
23 if trafo_reverse:
24 # calculate the trafo to put p2=(1,-1):
25 # (for the right branch only)
26 x2, y2 = Dx, Dy+1
27 tr1 = trafo.scale(1, -1.0/y2)
28 pp = tr1.apply_pt(x2, y2)
29 tr2 = trafo.trafo(matrix=((1, (pp[0]-1)), (0, 1)))
30 p = p.transformed(tr2*tr1)
31 c = canvas.canvas()
32 c.stroke(p, [deco.shownormpath()])
33 #c.text(-0.2, -10*unit.x_pt, r"\noindent$\Delta x=%g $\par\noindent$\Delta y=%g$"%(Dx,Dy),
34 # [text.parbox(4), text.size.footnotesize])
35 return c
37 dx = 3
38 dy = -3
40 Dy = -2.5
41 e = 0.1
42 # test the left branch:
43 cc = acurve(pass00(Dy), Dy) # passes through startpoint
44 #cc = acurve(Dx_m(Dy)-e, Dy)
45 c = acurve(Dx_m(Dy) , Dy); cc.insert(c, [trafo.translate(1*dx, 0)])
46 c = acurve(Dx_m(Dy)+e, Dy); cc.insert(c, [trafo.translate(2*dx, 0)])
48 # test the right branch:
49 #cc = acurve(Dx_p(Dy)-e, Dy, True)
50 #c = acurve(Dx_p(Dy) , Dy, True); cc.insert(c, [trafo.translate(1*dx, 0)])
51 ##c = acurve(Dx_p(Dy)+e, Dy, True); cc.insert(c, [trafo.translate(2*dx, 0)])
52 #c = acurve(pass10(Dy), Dy, True); cc.insert(c, [trafo.translate(2*dx, 0)]) # passes through endpoint
54 cc.writePDFfile()