2 import sys
;sys
.path
.insert(0, "..")
4 #sys.path.insert(0, os.path.expanduser("~/python/pyx-trunk"))
6 # File for invalid parametrisations of Bezier curves
10 return (-1-2*Dy
-sqrt((1+2*Dy
)**2+3))/3.0
13 return (-1-2*Dy
+sqrt((1+2*Dy
)**2+3))/3.0
16 return 1.0/(3.0*(Dy
+1))
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)
24 # calculate the trafo to put p2=(1,-1):
25 # (for the right branch only)
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
)
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])
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