Hi again,


Another METAPOST problem.  For the sake of curiosity, I've been looking at and playing with the superellipse() function in plain METAPOST.  This is all fine and dandy until I try values of 'superness' less than 0.5, in which case it generates shapes that are seemingly not superellipses.  At s=0.5, the function generates a diamond shape -- which, AFAIK, is correct.  However, s<0.5, the points of the diamond immediately turn to curves.  (My knowledge of superellipses here is just from http://en.wikipedia.org/wiki/Superellipse -- try the image at http://en.wikipedia.org/wiki/File:Lame_anima.gif to see how I expect the shape to change with varying values of superness).

Some code follows -- perhaps someone could run it and tell me if, for starters, they get the same as me.  (See http://i49.tinypic.com/2ijqatl.jpg for superellipse() with s=0.3).


Best,


James



% The following is a superellipse function at <http://lists.foundry.supelec.fr/pipermail/metapost-commits/2008-June/000340.html>;
% I think it's the superellipse function in my copy of METAPOST; it at least has the same behaviour.
% It seems to calculate the vertices correctly, but not the way they join (try changing all ... to --).
%
%def superellipse(expr r,t,l,b,s)=
%  r ... (s[xpart t,xpart r],s[ypart r,ypart t]){t-r} ...
%  t ... (s[xpart t,xpart l],s[ypart l,ypart t]){l-t} ...
%  l ... (s[xpart b,xpart l],s[ypart l,ypart b]){b-l} ...
%  b ... (s[xpart b,xpart r],s[ypart r,ypart b]){r-b} ... cycle
%enddef;

def supertest expr s =
  superellipse(
    ( 100, 50  ),
    ( 50,  100 ),
    ( 0,   50  ),
    ( 50,  0   ),
    s
    );
enddef;

% These >0 supernesses are fine, I think ...

beginfig(0);
  draw supertest 2;
endfig;

beginfig(1);
  draw supertest 1.01;
endfig;

% The following, 0.5>=superness<=1,
% are from visual reference definitely right

beginfig(2);
  draw supertest 1;
endfig;

beginfig(3);
  draw supertest 0.99;
endfig;

beginfig(4);
  draw supertest 0.7;
endfig;

beginfig(5);
  draw supertest 0.51;
endfig;

beginfig(6);
  draw supertest 0.5;
endfig;

% Now, for <0.5,
% things get problematic --
% the points in the shape generated by s=0.5
% should stay 'pointy'

beginfig(7);
  draw supertest 0.49;
endfig;

beginfig(8);
  draw supertest 0.3;
endfig;

beginfig(9);
  draw supertest 0.01;
endfig;

beginfig(10);
  draw supertest 0;
endfig;

end;