ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Mojca Miklavec <mojca.miklavec.lists@gmail.com>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Re: Asymptote in Context
Date: Sun, 28 Dec 2014 12:04:55 +0100	[thread overview]
Message-ID: <CALBOmsbqmJVxuEZhc0DyXahdZ8PuCTC=cESP-oMWcdf51Vzjiw@mail.gmail.com> (raw)
In-Reply-To: <alpine.OSX.2.02.1412280220100.98145@nqv-znpobbx>

[-- Attachment #1: Type: text/plain, Size: 1017 bytes --]

Dear Aditya,

On Sun, Dec 28, 2014 at 8:21 AM, Aditya Mahajan wrote:
> On Wed, 24 Dec 2014, Context NTG wrote:
>
>> Could anybody explain how to use Asymptote in ConTeXt with the filter
>> module.
>
> Can you post a minimal asymptote file and how it shoud be processed via the
> command line?

I have no time to create a nice minimal example, but here's an ugly
non-minimal example which should at least enable you to test the
interaction with the filter module.

I also added one ConTeXt-specific command while trying to make math
fonts work properly, just replace "lucidaot" with another font in case
you don't have that one installed.

You can run the example with
    asy -tex context cylinder.asy

(Maybe it's possible to set the tex engine inside the file as well.)


Bonus points if you can get PRC to work properly before TL 2015. Or if
you can make the file print properly from OS X without using Acrobat
or ghostscript/CUPS. Preview.app "forgets" to print the (smoothly
shaded) cylinder for example.

Mojca

[-- Attachment #2: cylinder.asy --]
[-- Type: application/octet-stream, Size: 2236 bytes --]

settings.outformat="pdf";
settings.render=0;
settings.prc=false;

// asy -tex context cylinder.asy
texpreamble("\setupbodyfont[lucidaot,8pt]");
//defaultpen(fontsize(8pt));
defaultpen(font("lucidaot", 8.0));

import solids;

size(0,120);

// Return a right circular cylinder of height h in the direction of axis
// based on a circle centered at c with radius r.
revolution halfcylinder(triple c=O, real r, real h, triple axis=Z, real angle1=0, real angle2=360)
{
  triple C=c+r*perp(axis);
  axis=h*unit(axis);
  return revolution(c,C--C+axis,axis,angle1,angle2);
}

revolution halfthickcylinder(triple c=O, real r1, real r2, real h, triple axis=Z, real angle1=0, real angle2=360)
{
  triple C=c+r1*perp(axis);
  triple dC=(r2-r1)*perp(axis);
  axis=h*unit(axis);
  return revolution(c,C--C+axis--C+axis+dC--C+dC--cycle,axis,angle1,angle2);
}

currentlight=light(4,-5,5);
currentprojection=orthographic(2,-5,0.6);

real r1=0.50, r2=0.52, h=0.40;
real px=0.1, py=px, pz=0.2;
real phi1=5, phi2=165;

surface patient = scale(px,py,pz)*shift(-0.5,-0.5,-0.5)*unitcube;

revolution ring1=rotate(-90,Y)*shift(0,-h/2,0)*halfthickcylinder(O,r1,r2,h,Y,phi1,phi2);
revolution ring2=yscale3(-1)*ring1;

real dax = 0.2;
draw((r2,0,r2)--(r2,0,r2+dax),blue,Arrow3);
label("$z$", (r2,0,r2+dax), N, blue);
draw((r2,0,r2)--(r2,dax,r2),green,Arrow3);
label("$y$", (r2,dax,r2), NE, green);
draw((r2,0,r2)--(r2+dax,0,r2),red,Arrow3);
label("$x$", (r2+dax,0,r2), E, red);


draw(surface(ring2),yellow);

draw(O--(rotate(-phi1,Y)*scale3(r2)*Z),dashed);
draw(O--(rotate(-phi2,Y)*scale3(r2)*Z),dashed);

label(format("$%.0f°$", phi1), (rotate(-phi1,Y)*scale3(r2)*Z), N);
label(format("$%.0f°$", phi2), (rotate(-phi2,Y)*scale3(r2)*Z), S);

real ax(real t) {return 0.5*r2*cos(t);}
real ay(real t) {return 0.5*r2*sin(t);}
real az(real t) {return 0;}
path3 ap=graph(ay,az,ax,0,-pi*phi2/180,operator ..);
draw(ap,Arrow3);
label("$\phi$", (rotate(-phi2/2,Y)*scale3(r2/2)*Z), W);


draw(scale3(-pz/2)*Z--scale3(-r2)*Z,red);
draw(scale3(-pz/2)*Z--scale3(pz/2)*Z,red+dashed);
draw(patient, blue+opacity(.7), 0.4bp+black);
draw(scale3(pz/2)*Z--scale3(r2)*Z,red);

draw(surface(ring1),yellow);

path3 ah = rotate(-30,Y)*shift(r2,0,0)*scale3(0.5*h)*((0,-1,0)--(0,1,0));


[-- Attachment #3: cylinder.pdf --]
[-- Type: application/pdf, Size: 57748 bytes --]

[-- Attachment #4: Type: text/plain, Size: 485 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
___________________________________________________________________________________

  reply	other threads:[~2014-12-28 11:04 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-24 21:41 Context NTG
2014-12-28  7:21 ` Aditya Mahajan
2014-12-28 11:04   ` Mojca Miklavec [this message]
2014-12-28 16:51     ` OT: " Alan BRASLAU
2014-12-28 17:07       ` luigi scarso
2014-12-29 15:03         ` Alan BRASLAU
2014-12-29 15:27           ` Arthur Reutenauer
2014-12-28 18:44       ` Mojca Miklavec
2015-01-02 22:14     ` Context NTG
2015-01-20  3:39       ` Aditya Mahajan
  -- strict thread matches above, loose matches on Subject: below --
2014-12-07 17:50 context context

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CALBOmsbqmJVxuEZhc0DyXahdZ8PuCTC=cESP-oMWcdf51Vzjiw@mail.gmail.com' \
    --to=mojca.miklavec.lists@gmail.com \
    --cc=ntg-context@ntg.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).