## Official Asymptote example – cos2theta

Category: Asymptote,Official Gallery One-PagerPh. Ivaldi @ 1 h 57 min

 (Compiled with Asymptote version 2.14svn-r5318)
/* This code comes from The Official Asymptote Gallery */

import graph;
size(0,100);

real f(real t) {return cos(2*t);}

path g=polargraph(f,0,2pi,operator ..)--cycle;
fill(g,green+white);
xaxis("$x$",above=true);
yaxis("$y$",above=true);
draw(g);

dot(Label,(1,0),NE);
dot(Label,(0,1),NE);



Étiquettes : ,

## Official Asymptote example – near_earth

Category: Asymptote,Official Gallery One-PagerPh. Ivaldi @ 3 h 57 min

 (Compiled with Asymptote version 2.14svn-r5318)
/* This code comes from The Official Asymptote Gallery */

import three;
import math;
texpreamble("\usepackage{bm}");

size(300,0);

pen thickp=linewidth(0.5mm);

currentprojection=perspective(4,1,2);

// Planes
pen bg=gray(0.9)+opacity(0.5);
draw(surface((1.2,0,0)--(1.2,0,1.2)--(0,0,1.2)--(0,0,0)--cycle),bg);
draw(surface((0,1.2,0)--(0,1.2,1.2)--(0,0,1.2)--(0,0,0)--cycle),bg);
draw(surface((1.2,0,0)--(1.2,1.2,0)--(0,1.2,0)--(0,0,0)--cycle),bg);

real r=1.5;
pen p=rgb(0,0.7,0);
draw(Label("$x$",1),O--r*X,p,Arrow3);
draw(Label("$y$",1),O--r*Y,p,Arrow3);
draw(Label("$z$",1),O--r*Z,p,Arrow3);
label("$\rm O$",(0,0,0),W);

// Point Q
label("$\rm Q$",pQ,N+3*W);
draw("$\lambda$",arc(O,0.15pQ,0.15*Z),N+0.3E);

// Particle
triple m=pQ-(0.26,-0.4,0.28);
real width=5;
dot("$m$",m,SE,linewidth(width));
draw("$\bm{\rho}$",(0,0,0)--m,Arrow3,PenMargin3(0,width));
draw("$\bm{r}$",pQ--m,Arrow3,PenMargin3(0,width));

// Spherical octant
real r=sqrt(pQ.x^2+pQ.y^2);
draw(arc((0,0,pQ.z),(r,0,pQ.z),(0,r,pQ.z)),dashed);

// Moving axes
triple i=dir(90+lambda,aux);
triple k=unit(pQ);
triple j=cross(k,i);

draw(Label("$x$",1),pQ--pQ+0.2*i,2W,red,Arrow3);
draw(Label("$y$",1),pQ--pQ+0.32*j,red,Arrow3);
draw(Label("$z$",1),pQ--pQ+0.26*k,red,Arrow3);

draw("$\bm{R}$",O--pQ,Arrow3,PenMargin3);
draw("$\omega\bm{K}$",arc(0.9Z,0.2,90,-120,90,160,CW),1.2N,Arrow3);



Étiquettes : , , , , ,

## Official Asymptote example – polararea

Category: Asymptote,Official Gallery One-PagerPh. Ivaldi @ 20 h 57 min

 (Compiled with Asymptote version 2.14svn-r5318)
/* This code comes from The Official Asymptote Gallery */

import math;
import graph;

size(0,150);

real f(real t) {return 5+cos(10*t);}

xaxis("$x$");
yaxis("$y$");

real theta1=pi/8;
real theta2=pi/3;
path k=graph(f,theta1,theta2,operator ..);
real rmin=min(k).y;
real rmax=max(k).y;
draw((0,0)--rmax*expi(theta1),dotted);
draw((0,0)--rmax*expi(theta2),dotted);

path g=polargraph(f,theta1,theta2,operator ..);
path h=(0,0)--g--cycle;
fill(h,lightgray);
draw(h);

real thetamin=3*pi/10;
real thetamax=2*pi/10;
pair zmin=polar(f(thetamin),thetamin);
pair zmax=polar(f(thetamax),thetamax);
draw((0,0)--zmin,dotted+red);
draw((0,0)--zmax,dotted+blue);

draw("$\theta_*$",arc((0,0),0.5*rmin,0,degrees(thetamin)),red+fontsize(10pt),
PenMargins);
draw("$\theta^*$",arc((0,0),0.5*rmax,0,degrees(thetamax)),blue+fontsize(10pt),
PenMargins);

draw(arc((0,0),rmin,degrees(theta1),degrees(theta2)),red,PenMargins);
draw(arc((0,0),rmax,degrees(theta1),degrees(theta2)),blue,PenMargins);



Étiquettes : , ,

## Official Asymptote example – polarcircle

Category: Asymptote,Official Gallery One-PagerPh. Ivaldi @ 21 h 57 min

 (Compiled with Asymptote version 2.14svn-r5318)
/* This code comes from The Official Asymptote Gallery */

import math;
import graph;
size(0,100);

real f(real t) {return 2*cos(t);}
pair F(real x) {return (x,f(x));}

draw(polargraph(f,0,pi,operator ..));

defaultpen(fontsize(10pt));

xaxis("$x$");
yaxis("$y$");

real r=f(theta);
draw("$\theta$",arc((0,0),0.5,0,degrees(theta)),red,Arrow,PenMargins);

pair z=polar(r,theta);
draw(z--(z.x,0),dotted+red);
draw((0,0)--(z.x,0),dotted+red);
label("$r\cos\theta$",(0.5*z.x,0),0.5*S,red);
label("$r\sin\theta$",(z.x,0.5*z.y),0.5*E,red);
dot("$(x,y)$",z,N);
draw("r",(0,0)--z,0.5*unit(z)*I,blue,Arrow,DotMargin);

dot("$(a,0)$",(1,0),NE);
dot("$(2a,0)$",(2,0),NE);



Étiquettes : , ,

## Official Asymptote example – spiral

Category: Asymptote,Official Gallery One-PagerPh. Ivaldi @ 6 h 57 min

 (Compiled with Asymptote version 2.14svn-r5318)
/* This code comes from The Official Asymptote Gallery */

size(0,150);
import graph;

real f(real t) {return exp(-t/(2pi));}

draw(polargraph(f,0,20*pi,operator ..));

xaxis("$x$",-infinity,1.3);
yaxis("$y$",-infinity,1);

labelx(1);
labelx("$e^{-1}$",1.0/exp(1),SE);



Étiquettes : , , ,

## Official Asymptote example – spiral3

Category: Asymptote,Official Gallery One-PagerPh. Ivaldi @ 7 h 57 min

 (Compiled with Asymptote version 2.14svn-r5318)
/* This code comes from The Official Asymptote Gallery */

import graph3;
import palette;

size3(10cm);

currentprojection=orthographic(5,4,2);
viewportmargin=(2cm,0);

real r(real t) {return 3exp(-0.1*t);}
real x(real t) {return r(t)*cos(t);}
real y(real t) {return r(t)*sin(t);}
real z(real t) {return t;}

path3 p=graph(x,y,z,0,6*pi,50,operator ..);

tube T=tube(p,2);
surface s=T.s;
s.colors(palette(s.map(zpart),BWRainbow()));
draw(s,render(merge=true));
draw(T.center,thin());



Étiquettes : , , , , ,

## Official Asymptote example – unitcircle

Category: Asymptote,Official Gallery One-PagerPh. Ivaldi @ 13 h 57 min

 (Compiled with Asymptote version 2.14svn-r5318)
/* This code comes from The Official Asymptote Gallery */

size(0,150);

pair z0=0;
pair z1=1;
real theta=30;
pair z=dir(theta);

draw(circle(z0,1));
filldraw(z0--arc(z0,1,0,theta)--cycle,lightgrey);
dot(z0);
dot(Label,z1);
dot("$(x,y)=(\cos\theta,\sin\theta)$",z);
arrow("area $\frac{\theta}{2}$",dir(0.5*theta),2E);
draw("$\theta$",arc(z0,0.7,0,theta),LeftSide,Arrow,PenMargin);



Étiquettes : , , , , ,