1

I am trying to reproduce the examples in Metapost showed here but I am having this error:

! An expression can't begin with `]'.

            0

               ]

l.12 vector e[] ,u[];

This is the code:

prologues:=3;                % include all fonts
outputtemplate:="%j-%c.mps"; % output file will be file.mps
beginfig(1);
phi:=25;                     % latitude
lambda:=28;                  % longitude
Omega=35;                    % longitude of ascending node
incl=30;                     % inclination
omega=43;                    % longitude of periapsis in orbital plane
vector e[],u[];
e1=(1,0,0);                  % aries - vernal equinox
e2=(0,1,0);                  % e2=e x e1 - not used
e3=(0,0,1);                  % e3=e=ENP
endfig;
end.

Any ideas why is this happening?

Mac
  • 13

1 Answers1

3

There is no vector type in MetaPost, you have to use pair instead, and as its names suggests, there must be two coordinates, not three. MetaPost is a 2D-based language.

See the featpost package for an example of MetaPost use for 3D drawings. See also the Asymptote language, which is inspired by MetaPost and has full 3D abilities.

Edit Reading the linked article more thoroughly, I finally learnt that the author uses a vector type defined by Denis Roegel in this TUGboat article.

let vector=color;
  let Xp=redpart; let Yp=greenpart; let Zp=bluepart;

In fact, it's down to the same thing used in featpost (and the tres module provided by Metafun, see Henri Menke's comment below): using the color type for 3D-coordinates…

Franck Pastor
  • 18,756
  • There is a three-pronged variant, but it’s for colors and is not suitable for coordinates. – egreg Mar 26 '18 at 19:57
  • @egreg As it happens, the featpost package I pointed in my answer uses the 3D color type for coordinates. :-) It seems to work, although I never tried it earnestly. – Franck Pastor Mar 26 '18 at 20:00
  • Naughty boys!!! – egreg Mar 26 '18 at 20:01
  • Metafun can do 3D as well using the tres module. In ConTeXt you can use it via the three module (this file also has examples). – Henri Menke Mar 26 '18 at 20:27
  • @HenriMenke It reminds me somehow of the method I used for this peculiar drawing (method which was in turn inspired by the pst-3dplot package documentation): https://tex.stackexchange.com/a/158746/25768 Anyway, it seems fairly limited compared to featpost, a fortiori compared to the extended 3D support provided by Asymptote. – Franck Pastor Mar 26 '18 at 20:35
  • @FranckPastor Is there any possible reason why he use vector type all over the document? – Mac Mar 26 '18 at 20:58
  • @Mac I've no idea… The best way to know it is probably to ask him directly. Maybe he uses some kind of self-made package I'm not aware of and which is not explicitly loaded in this document. – Franck Pastor Mar 26 '18 at 21:05
  • @Mac I've found it! He uses a kind of vector type defined in this paper of Denis Roegel: https://pdfs.semanticscholar.org/0408/16bbe007e5b8d1d794458a446521505d5b34.pdf I will edit my answer accordingly. – Franck Pastor Mar 26 '18 at 21:08
  • @FranckPastor I understand now! Thank you again – Mac Mar 26 '18 at 21:42