From: Andre Wobst <wobsta@us...>  20040727 20:13:18

Hi, On 27.07.04, Magnus Lie Hetland wrote: > I know the curves are > nonlinear... I just (naïvely ;) thought that, perhaps, through some > transformational magic the problem could be solved within the same > framework of linear equations. I don't think so. The intersection of two bezier curves is solved numerically. (Or may be by solving a polynom of grad three.) In case you want to take a look into MetaPost (I would like to learn more about that). Is it really possible to say: transform a path by a not yet completely defined transformation, so that an intersection point with another path is located at a y coordinate with a certain value? I just think you can't transform a path with a not yet completely defined transformation. It becomes too complicated. But, of course, what you can do for sure is to transform a point by a not yet completely defined transformation. This is how you can define a transformation by saying this point goes into this and a second one into another one etc. > [snip] > > Say p and p' are (2d) points, and t is a transformation (i.e. a 2x2 > > matrix + a 2d vector). Then you can write > > > > p' = t(p) > > > > Once you say p' and p are lazy vectors (i.e. they contain 2 variables) > > as well as t is a lazy transformation (i.e. it contain 6 variables), > > than the equation above is nonlinear. There are nonlinear terms in > > matrix times vector when they both contain variables. > > Right  you're basically saying that this isn't linear in the > elements of the transform? But if we freeze the transform it is linear > in p' and p...? Ok, lets do some ASCII art (is it art?): /x'\ /a b\/x\ /e\   =    +   \y'/ \c d/\y/ \f/ If you do not define the transformation matrix (i.e. the variables a, b, c, and d) and you also keep the point p, i.e. x and y, variable, the left hand side contains terms like a*x, which is nonlinear. You may, at a later point, find out, that you already know the value of x, for example. Than the term becomes linear ... And I think, that's what needs to be coded. > This seems quite muddled. I'm not very tempted to read the MetaPost > source code to find out how they do it either; I guess maybe I can > snoop around and see if I find some other pointers on how to do this > sort of thing. Or just think what we can code right now after thinking about the problem. I think its not that complex. Those nonlinear terms might be hidden in some additional "nonlinear variable" in a code along the lines I've started. Should be possible. Just replace a*x by AX and keep on going. Once a or x becomes available by other means, the "nonlinear variable" can be resolved and a linear equation is restored. What's also needed are equations for 2d points etc., but those might be build on top of the term class as well. So I think, yes, we can really get this working ... I've worked on my solver code a bit further. You can find an updated version enclosed. It solves equations "on the fly" and it also tries to solve equations as soon as possible (it searches for decoupled systems of equations). I've just checked it into the CVS under test/experimental/solve.py as well ... André PS: I've also seen your comment about isinstance. Right. Currently I'm using it in this solver code to differenciate in __add__ etc. between the different types. Not yet perfect, right ... ;) (I've the Python Cookbook and read about isstring, yes.)  by _ _ _ Dr. André Wobst / \ \ / ) wobsta@..., http://www.wobsta.de/ / _ \ \/\/ / PyX  High quality PostScript figures with Python & TeX (_/ \_)_/\_/ visit http://pyx.sourceforge.net/ 