From: Ken Starks <ken@la...>  20080825 18:28:35

Stefan Schenk wrote: > 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)) > >  > 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://moblincontest.org/redirect.php?banner_id=100&url=/ > _______________________________________________ > PyXuser mailing list > PyXuser@... > https://lists.sourceforge.net/lists/listinfo/pyxuser > > > There is a genuine problem here that would be useful to solve, in the context of involutes and evolutes, of constucting a curve as an envelope, and similar tasks. It is a task that should almost certainly be solved for parametric paths rather than graphs of functions, although they would be a special case. Another special case, that of applying unequal axisscaling, possibly not even linear, as here, is possible I suppose, but is quite likely to be silly. If you distort your geometry in this way, you should surely distort your ruler/tapemeasure and protractor to match. The idea of starting with such a pathological example as ("y(x)=sin(x)/x", min=10, max=10) is either tongueincheek, or a troll.  So let us start with the simpler (but not insubstantial) task: Same problem, but restricted to paths that consist of a single, nonselfintersecting cubic Bezier. Can this be solved analytically, and if not what is the most stable, accurate, and/or quickest numerical method that Python can provide ? I can't imagine that recursive chopping in half, followed by Pythagoras' theorem on all the bits is likely to be it. Cheers, Ken. 