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: Magnus Lie Hetland <magnus@he...>  20040727 17:52:28
Attachments:
geom.py

Luckily, I couldn't quite stop playing around with this... My first thought was to rewrite everything, writing custom stuff to integrate the linear equation solving stuff and my lazy points. I guess that is still an option, but I decided to do a very simple version instead. So, here is a version which uses Andr=E9's linear equation stuff (although I've switched to numarray  it's what I use; and numarray 1.0 is out now, so... Hooray for that :). A point is simply a list of variables. By using ordinary list notation, such as p[0] one gets at these variables (their values are available through p[0].value and so forth) but by using the syntactic sugar p.x (or p.y or p.z) one gets (or sets) their values. For general dimensions beyond the third, use p.get(dim) or p.set(dim, val) (or, equivalently, p[dim].value and p[dim].value =3D val). The lsys class is a simple wrapper that handles left and right hand sides with more than one element (for multidimensional equations). There is precious little one can do directly with points at the moment (such as addition/multiplication) but adding that should be easy. I've added a single transformation as an example: """ def rotated(point, a): assert len(point) =3D=3D 2 # To keep it simple :) return (point[0]*cos(a)point[1]*sin(a), point[1]*cos(a)+point[0]*sin(a)) """ Note that this works with the *variables*, not their *values*. Thus, one can use this transform either way in an equation: """ from geom import * from math import pi a =3D pt() b =3D pt() c =3D pt() eqs =3D lsys() a.x =3D 0 a.y =3D 10 eqs.eq(a, rotated(b, pi/2)) eqs.eq(c, rotated(a, pi/2)) eqs.solve() print b.x, b.y # Prints out 10.0 0.0 print c.x, c.y # Prints out 10.0 0.0 """ So, presto, we've got a bidirectional thingy. Note that the angle in the transform is still a constant, though. As Andr=E9 pointed out, if the angle is to be a variable, we'd end up getting equations with sin() and cos(), and that's not exactly pleasant. So, this code is still sort of hackish, but it's a starting point that actually works... And that's always good, isn't it? :) =20 Magnus Lie Hetland "Canned Bread: The greatest thing since sliced http://hetland.org bread!" [from a can in Spongebob Squarepants] 
From: Andre Wobst <wobsta@us...>  20040727 20:18:19

Hi Magnus, On 27.07.04, Magnus Lie Hetland wrote: > Luckily, I couldn't quite stop playing around with this... As for me. I was offline the last hours I noticed you posting just now. I'll take a look at your ideas tomorrow. In the mean I've posted an updated version of my solve.py ... André  by _ _ _ Dr. André Wobst / \ \ / ) wobsta@..., http://www.wobsta.de/ / _ \ \/\/ / PyX  High quality PostScript figures with Python & TeX (_/ \_)_/\_/ visit http://pyx.sourceforge.net/ 
From: Andre Wobst <wobsta@us...>  20040728 06:23:26

Hi, On 27.07.04, Magnus Lie Hetland wrote: > So, here is a version which uses André's linear equation stuff > (although I've switched to numarray  it's what I use; and numarray > 1.0 is out now, so... Hooray for that :). Hey, isn't that something for tryimportexcept? No isinstance available ... ;) > So, presto, we've got a bidirectional thingy. Note that the angle in > the transform is still a constant, though. As André pointed out, if > the angle is to be a variable, we'd end up getting equations with > sin() and cos(), and that's not exactly pleasant. Well, I have to look at MetaPost at some point. Don't we really want to create a transformation by setting 3 2d input and output points? This is a linear problem. How is it in MetaPost? Is it allowed to define write P = t*p where the points P and p are not defined as well as t is not defined? What does MetaPost with such an equation? Does it store it for later evaluation (for example until p and P becomes known)? And what about having several transformations: P = t2*t1*p? And what about restricting a transformation to a rotation, for example? I should take a look at MetaPost/MetaFont at some point. André  by _ _ _ Dr. André Wobst / \ \ / ) wobsta@..., http://www.wobsta.de/ / _ \ \/\/ / PyX  High quality PostScript figures with Python & TeX (_/ \_)_/\_/ visit http://pyx.sourceforge.net/ 
From: Magnus Lie Hetland <magnus@he...>  20040728 20:10:54

Andre Wobst <wobsta@...>: > [snip] > Well, I have to look at MetaPost at some point. If you mean a the language/user level  indeed. Very relevant to PyX. But I guess, perhaps, you mean at the implementation/code level? Well... I guess it's still relevant (although I'm not sure I'd dare venture into that without a good lantern and a trusty sword by my side... Or something :]) > Don't we really want to create a transformation by setting 3 2d > input and output points? That's the canonical problem, I guess. > This is a linear problem. How is it in MetaPost? There's an example on page 32 of the User Manual; the transform T (called T' in the manual) is not yet defined: (0, 1) transformed T =3D (3, 4) (1, 1) transformed T =3D (7, 1) (1, 0) transformed T =3D (4, 3) The solugion to this gives the transform factors txx =3D 4 txy =3D 3 [called tyx in the manual] tyx =3D 3 tyy =3D 4 tx =3D 0 ty =3D 0 But the problem needn't be this straightforward; these equations must be fully integrated with the general equation stuff, of course. For example, on the same page in the manual, the following equations are used to specify that a given (as yet unknown) transform is shapepreserving: txx =3D tyy; tyx =3D txy This automatically only allows rotation, shifting and uniform scaling. This is used in a very neat example on page 33 of the manual (figure 28). > Is it allowed to define write P =3D t*p where the points P and p are > not defined as well as t is not defined? What does MetaPost with > such an equation? Does it store it for later evaluation I don't really know; for each nonlinear term you have to know (*or* be able to figure out through some other linear equation system) one of the two factors before you can start solving things, of course. But how you deal with this in general (i.e. how you know when to solve a certain subset of the equations but not the rest of the equations) I don't know. > (for example until p and P becomes known)? And what about having > several transformations: P =3D t2*t1*p? I would think that would be allowed (as long as you supplied more equations in addition) but I'm not sure. > And what about restricting a transformation to a rotation, for > example? That can certainly be done (see the example above). > I should take a look at MetaPost/MetaFont at some point. Sounds like a good move, indeed :) I guess one of the few reasons I haven't dropped MetaPost is that PyX doesn't quite implement all of its functionality (such as this) yet. :] (Also, it's nice to be able to use the output from MetaPost directly in pdflatex without a hickup; if PyX could restrict itself to the same subset of EPS, possibly with a switch, such as mps=3DTrue or something, that would be very nice :}) > Andr=E9 =20 Magnus Lie Hetland "Canned Bread: The greatest thing since sliced http://hetland.org bread!" [from a can in Spongebob Squarepants] 
From: Andre Wobst <wobsta@us...>  20040729 07:18:34

Hi, On 28.07.04, Magnus Lie Hetland wrote: > (Also, it's nice to be able to use the output from MetaPost directly > in pdflatex without a hickup; if PyX could restrict itself to the same > subset of EPS, possibly with a switch, such as mps=True or something, > that would be very nice :}) We'll probably support direct PDF output much sooner. Next week? No, probably not. But within a few month I (and Jörg) should find some time to finish it. Originally I thought about having this for 0.7 already. I'm not that sure whether we can make that. 0.7 needs to be release on not to far future ... André PS: <sarcasm> Isn't MetaPost always a hickup? It does not even produce viewable/printable files (i.e. embedding the fonts it uses). </sarcasm>  by _ _ _ Dr. André Wobst / \ \ / ) wobsta@..., http://www.wobsta.de/ / _ \ \/\/ / PyX  High quality PostScript figures with Python & TeX (_/ \_)_/\_/ visit http://pyx.sourceforge.net/ 
From: Magnus Lie Hetland <magnus@he...>  20040729 08:07:35

Andre Wobst <wobsta@...>: > > Hi, >=20 > On 28.07.04, Magnus Lie Hetland wrote: > > (Also, it's nice to be able to use the output from MetaPost directly > > in pdflatex without a hickup; if PyX could restrict itself to the sam= e > > subset of EPS, possibly with a switch, such as mps=3DTrue or somethin= g, > > that would be very nice :}) >=20 > We'll probably support direct PDF output much sooner. Next week? No, > probably not. But within a few month I (and J=F6rg) should find some > time to finish it. Originally I thought about having this for 0.7 > already. I'm not that sure whether we can make that. 0.7 needs to be > release on not to far future ... One solution would be to use epstopdf or something externally; you already do this sort of thing with TeX, so... (I've used this solution in my own programs.) > Andr=E9 >=20 > PS: <sarcasm> Isn't MetaPost always a hickup? It does not even produce > viewable/printable files (i.e. embedding the fonts it uses). </sarcasm> Heh. I only use it together with pdflatex, and then it works wonderfully. =20 Magnus Lie Hetland "Canned Bread: The greatest thing since sliced http://hetland.org bread!" [from a can in Spongebob Squarepants] 
From: Andre Wobst <wobsta@us...>  20040729 09:03:45

Hi, On 29.07.04, Magnus Lie Hetland wrote: > > PS: <sarcasm> Isn't MetaPost always a hickup? It does not even produce > > viewable/printable files (i.e. embedding the fonts it uses). </sarcasm> > > Heh. I only use it together with pdflatex, and then it works > wonderfully. I'm still in sarcasm mode: MetaPost is a tool suitable for a single niche, i.e. to be used together with TeX and Co. However, MetaPost does not create PostScript files (at least PostScript files containing text). (I know, there is mproof, but what's that an ugly solution.) PyX is able to create PostScript files to be used whereever you want. Even on a printer ... ;) André  by _ _ _ Dr. André Wobst / \ \ / ) wobsta@..., http://www.wobsta.de/ / _ \ \/\/ / PyX  High quality PostScript figures with Python & TeX (_/ \_)_/\_/ visit http://pyx.sourceforge.net/ 
From: Magnus Lie Hetland <magnus@he...>  20040729 10:24:43

Andre Wobst <wobsta@...>: > > Hi, >=20 > On 29.07.04, Magnus Lie Hetland wrote: > > > PS: <sarcasm> Isn't MetaPost always a hickup? It does not even prod= uce > > > viewable/printable files (i.e. embedding the fonts it uses). </sarc= asm> > >=20 > > Heh. I only use it together with pdflatex, and then it works > > wonderfully. >=20 > I'm still in sarcasm mode: MetaPost is a tool suitable for a single > niche, i.e. to be used together with TeX and Co. However, MetaPost > does not create PostScript files (at least PostScript files containing > text). (I know, there is mproof, but what's that an ugly solution.) >=20 > PyX is able to create PostScript files to be used whereever you want. > Even on a printer ... ;) But then again  PyX also uses TeX; you've just hidden it better ;) > Andr=E9 =20 Magnus Lie Hetland "Canned Bread: The greatest thing since sliced http://hetland.org bread!" [from a can in Spongebob Squarepants] 
From: Andre Wobst <wobsta@us...>  20040729 10:46:25

Hi, On 29.07.04, Magnus Lie Hetland wrote: > > PyX is able to create PostScript files to be used whereever you want. > > Even on a printer ... ;) > > But then again  PyX also uses TeX; you've just hidden it better ;) Wasn't that point related to the discussion about integration of ghostscript to allow for various output formats? Beside that I thought that TeX is linked into MetaPost directly instead of running it as an external program. I would call linking programs together a better integration. André  by _ _ _ Dr. André Wobst / \ \ / ) wobsta@..., http://www.wobsta.de/ / _ \ \/\/ / PyX  High quality PostScript figures with Python & TeX (_/ \_)_/\_/ visit http://pyx.sourceforge.net/ 
From: Magnus Lie Hetland <magnus@he...>  20040729 11:00:17

Andre Wobst <wobsta@...>: > > Hi, >=20 > On 29.07.04, Magnus Lie Hetland wrote: > > > PyX is able to create PostScript files to be used whereever you wan= t. > > > Even on a printer ... ;) > >=20 > > But then again  PyX also uses TeX; you've just hidden it better ;) >=20 > Wasn't that point related to the discussion about integration of > ghostscript to allow for various output formats? Beside that I thought > that TeX is linked into MetaPost directly instead of running it as an > external program. I would call linking programs together a better > integration. Not sure. I don't think it uses TeX as a library, at least (as a TeX library doesn't really exist, although there is work on one now). I think it simply executes TeX in the background. My point was that you have to use TeX again afterward and include the MetaPost graphics to get a document with properly embedded fonts etc. You do that bit automatically. Oh, well. I was just poking fun (in response to your sarcasm mode) and don't really know what I'm talking about here ;) > Andr=E9 =20 Magnus Lie Hetland "Canned Bread: The greatest thing since sliced http://hetland.org bread!" [from a can in Spongebob Squarepants] 
From: Joerg Lehmann <joergl@us...>  20040729 07:19:13

Hi Magnus, On 28.07.04, Magnus Lie Hetland wrote: > Andre Wobst <wobsta@...>: > > > [snip] > > Well, I have to look at MetaPost at some point. > > If you mean a the language/user level  indeed. Very relevant to PyX. > But I guess, perhaps, you mean at the implementation/code level? > Well... I guess it's still relevant (although I'm not sure I'd dare > venture into that without a good lantern and a trusty sword by my > side... Or something :]) Fortunately, we already have some dungeon experience aquired in other parts of the TeX code. In particular, you need some mighty global variable protection shield... [snip] > (Also, it's nice to be able to use the output from MetaPost directly > in pdflatex without a hickup; if PyX could restrict itself to the same > subset of EPS, possibly with a switch, such as mps=True or something, > that would be very nice :}) ... or use the PDF output, which however is not yet totally finished. Jörg 
Sign up for the SourceForge newsletter:
No, thanks