Screenshot instructions:
Windows
Mac
Red Hat Linux
Ubuntu
Click URL instructions:
Rightclick on ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)
From: Mico Filós <elmico.filos@gm...>  20080822 18:36:49

Hi, I am sorry if this is a trivial question but I cannot figure out how to do this. Imagine I have a nonlinear function f(x) and its linearization at some point (x0,f(x0)), given by y(x) = f'(x0) (x  x0) + y0, where y0 = f(x0). Imagine also that I don't use the same scale for the x and y axes. How can I obtain a straight line that *looks* perpendicular to the tangent y(x)? Since the x and y scales are not the same, a line with slope equal to 1/f'(x0) does not look perpendicular to y(x). I want to plot a straight line that passes through an arbitrary point of the tangent (not necessarily (x0,y0)) and that looks perpendicular to it. My idea is actually to plot the projection of an arbitrary point of the nonlinear function, (x1,f(x1)) to the subspace spanned by the tangent at x0. For me the most straightforward thing to do would be: * Compute the angle theta (on the actual canvas, i.e., as it looks on the screen) of the path defined by the tangent function y(x) * Plot a line path L with an angle theta + pi/2 that passes through some particular point of the tangent Q=(x0', y0'), which I specify. * Find the intersection R of the line L with the path defined by the nonlinear function. * Ideally, I would stroke only the portion of L that connects the point (x0',y0') with the intersection point R. Describing this in words is painful. I hope you see what I mean. Thanks a lot in for your patience. Mico 
From: Stefan Schenk <Stefan.Schenk@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)) 
From: André Wobst <wobsta@us...>  20080825 17:36:12

Hi Stefan, Am 25.08.2008 um 10:57 schrieb Stefan Schenk: > Does anyone know a way in pyx to translate some graphcoordinate x > into a > pathlength? Didn't you pointed out that using path "arithmetics" would be a perfect solution to the problem. Well, here too! Just use a grid path from the axis: l = f.path.intersect(g.xgridpath(0.2))[0][0] Note that l will be a normpathparam instead of a simple length, but this is a feature ... and you can do funny things with those parameters (like adding an arc length to such a parameter). André  by _ _ _ Dr. André Wobst, Amselweg 22, 85716 Unterschleißheim / \ \ / ) wobsta@..., http://www.wobsta.de/ / _ \ \/\/ / PyX  High quality PostScript and PDF figures (_/ \_)_/\_/ with Python & TeX: visit http://pyx.sourceforge.net/ 
Sign up for the SourceForge newsletter:
No, thanks