Hi Mico,
Am Freitag 22 August 2008 20:36 schrieb Mico Filós:
[...]
> Describing this in words is painful. I hope you see what I mean.
I think i now understand the pain;-) You want to achieve something like the
following?
#------------------------------------------------------------------------------
from pyx import *
g = graph.graphxy(width=8)
f = g.plot(graph.data.function("y(x)=sin(x)/x", min=-10, max=10))
g.doplot(f)
# The point that defines the tangent
l = 0.51*f.path.arclen()
x0, y0 = f.path.at(l)
tangent = f.path.tangent(l, length=4)
g.stroke(tangent)
# Path that is perpendicular to tangent
projector = tangent.transformed(trafo.rotate(90, x0, y0))
# Some other arbitrary point
l2 = 0.7*f.path.arclen()
x1, y1 = f.path.at(l2)
# Find the intersection of a line from x1, y1 perpendicular to tangent with
# tangent
a, b = projector.transformed(trafo.translate(x1-x0,
y1-y0)).intersect(tangent)
u, v = tangent.at(b[0])
g.stroke(path.line(x1, y1, u, v))
g.writeEPSfile("project_function_to_tangent")
#------------------------------------------------------------------------------
However there is still the problem that the points (x0, y0) and (x1, y1)
are determined by some length of the path.
Does anyone know a way in pyx to translate some graph-coordinate x into a
path-length?
If not, you probably have to do tangent by hand and (x1, y1) will be
something like
x1, y1 = g.pos(x, y(x))
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
PyX-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/pyx-user