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
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

Any ideas why is this happening?


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…

  • 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): 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.