From: Stefan Schenk <Stefan.S<chenk@ph...>  20080825 08:58:07

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(x1x0, y1y0)).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 graphcoordinate x into a pathlength? If not, you probably have to do tangent by hand and (x1, y1) will be something like x1, y1 = g.pos(x, y(x)) 