Asymptote

From Liki

Jump to: navigation, search

Asymptote is a LaTeX-integrated graphics package like Metapost. It claims to be Metapost's successor, so it should have a cleaner syntax and better support.

There are good tutorials here and here. This example shows how to embed Asymptote code in LaTeX, with a more thorough introduction here. The full documentation is here.

[edit] Simple 3D example

Here is a simple graphic I made for my E&M class. Note that 3D perspective is simple with the ‘three’ module.

Example Asymptote graphic

import three;

real u = 1cm;
currentprojection=perspective(50u,-20u,0);
path3 cir = unitcircle3;
path3 cyl[] = cir ^^ (shift((0,0,1))*cir) ^^ (0,1,0)--(0,1,1) ^^ (0,-1,0)--(0,-1,1);
currentpen = blue;
for (int i; i < cyl.length; i+=1)
  draw(yscale3(5)*rotate(-90,(1,0,0))*scale3(u)*cyl[i]);
currentpen = red;
for (int i; i < cyl.length; i+=1)
  draw(yscale3(5)*rotate(90,(1,0,0))*scale3(u)*cyl[i]);
currentpen = black;

label("$\rho_a$", (0,2.5u,0));
label("$\rho_c$", (0,-2.5u,0));
draw((0,-1u,0)--(0,1u,0), Arrow);
label("$I$", (0, 1u,0), E);

label("$A$", (0, -5.5u, 0));
draw((0,-5u,-u)--(0,-5u,u));
label("$d$", (0, -4.9u /*hack*/, 0), W);

draw((0,-5u,-1.1u)--(0,0,-1.1u), Arrows);
label("$l$, $R_c$, $V_c$", (0, -2.5u,-1.1u), S);
draw((0,5u,-1.1u)--(0,0,-1.1u), Arrows);
label("$l$, $R_a$, $V_a$", (0, 2.5u,-1.1u), S);
draw((0,-5u,1.1u)--(0,5u,1.1u), Arrows);
label("$R_T$, $V_T$", (0, 0,1.1u), N);
Personal tools