ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* METAPOST's superellipse with superness<0.5 does not give a superellipse
@ 2010-03-01 15:54 James Fisher
  2010-03-01 16:04 ` James Fisher
  0 siblings, 1 reply; 6+ messages in thread
From: James Fisher @ 2010-03-01 15:54 UTC (permalink / raw)
  To: mailing list for ConTeXt users


[-- Attachment #1.1: Type: text/plain, Size: 2368 bytes --]

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.jpgfor 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;

[-- Attachment #1.2: Type: text/html, Size: 2974 bytes --]

[-- Attachment #2: Type: text/plain, Size: 486 bytes --]

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2010-03-02 21:40 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-03-01 15:54 METAPOST's superellipse with superness<0.5 does not give a superellipse James Fisher
2010-03-01 16:04 ` James Fisher
2010-03-01 16:20   ` Rory Molinari
2010-03-01 17:57     ` James Fisher
2010-03-01 19:15       ` Rory Molinari
2010-03-02 21:40         ` James Fisher

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).