Page d'accueil du laboratoire > Équipe de Probabilités > Page principale > MetaPost
Propaganda, Exemples, m3Dplain, Statsmac-mps, Animations, Transparence,

lego brick

m3D (in progress...)

m3Dmanual.pdf or better



MetaFont and MetaPost are nice languages for drawing two dimensional objects like fonts or technical drawings. They are certainly the most natural tools when using the TeX formatting system. So that TeX' users may learn and use them for their common formatting tasks.

The matter is that we have to learn also many other communication technics just as Web-stuff. Doing all from TeX-MetaFont(Post) basic knowledge would be for some people (at least for me) quite appreciable.

One thing I like is three dimensional animations. Many years ago, Denis Roegel has created his own MetaPost's format for such things, but it was too complicated for me. So I felt like designing my own extension of MetaPost language at least for some simple three dimensional pictures.

I do not attempt to provide some definitive package. I have not even really written a real or complete manual for my programs. I think that any acquainted MetaPost user may understand what they contain by reading them and find maybe some ideas for writting his/her owns.

Among links on this subject, one finds also Luis Nobre's FeatPost, Laurence Finston's GNU 3DLDF, Denis Roegel's MP2GL, ... nice things. It is also a pleasure to link this page to mold3D, a very impressive MetaPost contribution for drawing molecules due to Yang Wang.

The latest version of a very incomplete manual is here ps.gz, or pdf.

Some recent pictures

In order of appearence, one has: a quite strange chair (suggested by Jens Schwaiger, see also this page), the Viviani's window, 4 steps of the Sierpinski-Menger sponge, 2 use of a ‘rope’, the sponge again, the gasket (level 5), some curious thing using ‘revolution’, some C6, nothing in particular.

m3Dchair1 viviani
Sierpinski sponges
m3Dtest2 m3Dtest3
m3Dtest4 m3Dtest5

Latest downloads

Since, the more pictures one designs, the more efficient programming becomes, I've come to those very non-perfect and unstable programs which are included in the archive m3D.tar.gz:

Things change from time to time. At the beginning of year 2005, I changed my QuickSort implementation: its arguments form a list and its output is the corresponding ordered list stored into the SortedList control sequence. Sorting is done by handing sublists which are stored in temporary control sequences and passed through recursion as lists. This is nothing else but lists. Formerly I used temporary strings to do part of the job which was quite clumsy and slow. The size of the lists is limited by the size of MetaPost input stack (150 on my computer). For larger lists one should design its own sort algorithm.

Still about sorting and strings there is the OnDepth environment. Its former implementation was

  Refpoint ... Action "...";

Its role is to perform various actions in an order depending of the depth with respect to the observer of the associated reference points. The problem was to store the text of every action and to be able to use it in the proper order when executing endOnDepth. So I stored actions into temporary strings which would be then scanned by scantokens. First this was ugly, then it was also inefficient since the text of each action could not have contained symbolic tokens as macro or loop parameter. Now the syntax is

  Refpoint ...;
  Action (...);

One must notice that a semicolon must follow the argument of Refpoint. The argument of Action is a delimited text (no more a string). It is stored into a variable control sequence. The trick is that the suffix of this control sequence could not have been a number, I had to replace it by a pseudo-romannumeral (here is the trick).

Thanks and comments

A nice way for drawing the Sierpinski-Menger sponge as been suggested to us by Elvire Scheibling: in place of removing stuff from an initial cube, just take the smallest cube, copy it 20 times to get the first level sponge, and do the same copying again with this new cube. The problem is that this construction always requires a geometrically growing memory room. By the way I recently changed the implementation of the Sierpinski-Menger sponge ( The program is much heavier but it leads to some slightly lighter pictures.

Even for simple composite objects like this sponge, sorting is needed. I'm grateful to Pascal Grosse for his brightfull explanations of the Quick Sort algorithm.

Making an animation is merging many pictures into a movie. The starting point of the control sequences I use for that was the 3D package of Denis Roegel.

A very few people tried to use my macros and gave me, in some way, some feed back. They are usually real advanced MetaPost users (and will recognize them). I warmly thank them for the interest they have for my attempts in 3 dimensions.

Copyright: HTML's texts or graphics are free of any copyright, they are copyleft. TeX programs are also copyleft but one can send a postcard. MetaPost programs have just a feel-free-to-send-me-a-postcard licence. MetaFont programs have a send-me-a-postcard licence.
Valid HTML 4.01!
Anthony Phan,
Département de Mathématiques, SP2MI,
Boulevard Marie et Pierre Curie, Téléport 2,
BP 30179, F-86962 Futuroscope-Chasseneuil cedex