1 import sys
; sys
.path
.insert(0, "../..")
6 p
= path
.curve(-1, 0, 1, a
, -1, a
, 1, 0)
8 t
= trafo
.rotate(30).scaled(5)
15 t
= p
.normsubpaths
[0].trafo([x
])[0]
16 if t
is not path
.invalid
:
17 c
.stroke(path
.line(0, 0, 1, 0), [p
.normsubpaths
[0].trafo([x
])[0], deco
.earrow
.normal
, color
.rgb
.red
])
19 c
.text(-6, -5, "t=%f" % x
)
20 c
.text(-6, -5.5, "$x(t)=%f$" % (2.54/72*p
.normsubpaths
[0].normsubpathitems
[0].x_pt(x
)))
21 c
.text(-6, -6, "$\dot x(t)=%f$" % (2.54/72*p
.normsubpaths
[0].normsubpathitems
[0].xdot_pt(x
)))
22 c
.text(-6, -6.5, "$\ddot x(t)=%f$" % (2.54/72*p
.normsubpaths
[0].normsubpathitems
[0].xddot_pt(x
)))
23 c
.text(-3, -5.5, "$y(t)=%f$" % (2.54/72*p
.normsubpaths
[0].normsubpathitems
[0].y_pt(x
)))
24 c
.text(-3, -6, "$\dot y(t)=%f$" % (2.54/72*p
.normsubpaths
[0].normsubpathitems
[0].ydot_pt(x
)))
25 c
.text(-3, -6.5, "$\ddot y(t)=%f$" % (2.54/72*p
.normsubpaths
[0].normsubpathitems
[0].yddot_pt(x
)))
26 c
.text(0, -6, "datan2$(\dot y(t), \dot x(t))=%f$" % (math
.atan2(2.54/72*p
.normsubpaths
[0].normsubpathitems
[0].ydot_pt(x
), 2.54/72*p
.normsubpaths
[0].normsubpathitems
[0].xdot_pt(x
))*180/math
.pi
))
27 c
.text(0, -6.5, "datan2$(\ddot y(t), \ddot x(t))=%f$" % (math
.atan2(2.54/72*p
.normsubpaths
[0].normsubpathitems
[0].yddot_pt(x
), 2.54/72*p
.normsubpaths
[0].normsubpathitems
[0].xddot_pt(x
))*180/math
.pi
))
29 g
= c
.insert(graph
.graphxy(width
=10, xpos
=-5, ypos
=-20, key
=graph
.key
.key(), y
=graph
.axis
.lin(min=-10, max=10)))
30 g
.plot(graph
.data
.functionxy(lambda t
: 2.54/72*p
.normsubpaths
[0].normsubpathitems
[0].y_pt(t
), title
="$y(t)$", min=0, max=1))
31 g
.plot(graph
.data
.functionxy(lambda t
: 2.54/72*p
.normsubpaths
[0].normsubpathitems
[0].ydot_pt(t
), title
="$\dot y(t)$", min=0, max=1))
32 g
.plot(graph
.data
.functionxy(lambda t
: 2.54/72*p
.normsubpaths
[0].normsubpathitems
[0].yddot_pt(t
), title
="$\ddot y(t)$", min=0, max=1))
33 g
.stroke(g
.xgridpath(x
), [color
.rgb
.red
])
34 g
.stroke(g
.ygridpath(0))
36 g
= c
.insert(graph
.graphxy(width
=10, xpos
=-5, ypos
=0.5+g
.ypos
+g
.height
, key
=graph
.key
.key(), x
=graph
.axis
.linkedaxis(g
.axes
["x"]), y
=graph
.axis
.lin(min=-10, max=10)))
37 g
.plot(graph
.data
.functionxy(lambda t
: 2.54/72*p
.normsubpaths
[0].normsubpathitems
[0].x_pt(t
), title
="$x(t)$", min=0, max=1))
38 g
.plot(graph
.data
.functionxy(lambda t
: 2.54/72*p
.normsubpaths
[0].normsubpathitems
[0].xdot_pt(t
), title
="$\dot x(t)$", min=0, max=1))
39 g
.plot(graph
.data
.functionxy(lambda t
: 2.54/72*p
.normsubpaths
[0].normsubpathitems
[0].xddot_pt(t
), title
="$\ddot x(t)$", min=0, max=1))
40 g
.stroke(g
.xgridpath(x
), [color
.rgb
.red
])
41 g
.stroke(g
.ygridpath(0))
43 c
.writeEPSfile("cusp")