## Asymptote using three.asy – fig0010

Category: Asymptote,Examples 3D,three.asyPh. Ivaldi @ 14 h 50 min

 (Compiled with Asymptote version 2.14svn-r5318)

/* One may view this animated example */
import three;

size(12cm);
currentprojection=orthographic(1,1,1.5);
currentlight=(1,0,1);

triple P00=-X-Y+0.5*Z, P03=-X+Y, P33=X+Y, P30=X-Y;

triple[][] P={
{P00,P00+(-0.5,0.5,-1),P03+(0,-0.5,1),P03},
{P00+(0.5,-0.5,-1),(-0.5,-0.5,0.5),(-0.5,0.5,-1.5),P03+(0.5,0,1)},
{P30+(-0.5,0,1),(0.5,-0.5,-1.5),(0.5,0.5,1),P33+(-0.5,0,1)},
{P30,P30+(0,0.5,1),P33+(0,-0.5,1),P33}
};

surface s=surface(patch(P));
draw(s,15,15,yellow,meshpen=grey);
draw(sequence(new path3(int i){
return s.s[i].external();},s.s.length), bp+red);

dot("P[0][0]",P[0][0], align=N, black);
dot("P[0][3]",P[0][3], black);
dot("P[3][3]",P[3][3], align=S, black);
dot("P[3][0]",P[3][0], align=W, black);

draw(Label("P[0][1]",align=SW,EndPoint),P[0][0]--P[0][1], Arrow3);
draw(Label("P[1][0]",align=SE,EndPoint),P[0][0]--P[1][0], Arrow3);

draw(Label("P[0][2]",align=E,EndPoint),P[0][3]--P[0][2], Arrow3);
draw(Label("P[1][3]",EndPoint),P[0][3]--P[1][3], Arrow3);

draw(Label("P[2][3]",EndPoint),P[3][3]--P[2][3], Arrow3);
draw(Label("P[3][2]",EndPoint),P[3][3]--P[3][2], Arrow3);

draw(Label("P[3][1]",EndPoint),P[3][0]--P[3][1], Arrow3);
draw(Label("P[2][0]", align=W,EndPoint),P[3][0]--P[2][0], Arrow3);

dot("P[1][1]",P[1][1], align=S);
dot("P[1][2]",P[1][2], align=E);
dot("P[2][2]",P[2][2], align=N);
dot("P[2][1]",P[2][1], align=W);

for (int i=0; i < s.s.length; ++i)
dot(s.s[i].internal(), bp+red);

if(!is3D())
shipout(bbox(Fill(lightgrey)));



Étiquettes : , , , ,

## Asymptote using three.asy – fig0040

Category: Asymptote,Examples 3D,three.asyPh. Ivaldi @ 17 h 50 min

 (Compiled with Asymptote version 2.14svn-r5318)

import three;
size(8cm,0);

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,bg);
draw(surface((0,1.2,0)--(0,1.2,1.2)--(0,0,1.2)--(0,0,0)--cycle),bg,bg);
draw(surface((1.2,0,0)--(1.2,1.2,0)--(0,1.2,0)--(0,0,0)--cycle),bg,bg);

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

dot("$R*\mathrm{dir}\left(\theta,\phi\right)$",pQ);

// Arcs
draw("$\theta$", reverse(arc(O,0.5*pQ,0.5*Z)), N+0.3E, Arrow3(HookHead2));
draw("$\phi$", arc(O,0.5*X,0.5*(pQ.x,pQ.y,0)), N+0.3E, Arrow3(HookHead2));

draw(surface(p3), blue+opacity(0.5));



É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 : , , , , ,

## Animation with Asymptote – fig0200

Category: Animation,AsymptotePh. Ivaldi @ 3 h 20 min

 (Compiled with Asymptote version 1.86svn-r4626)
This animation is available in the Syracuse web site.

/* One may want to play with an interactive Java applet */
settings.render=0;
import three;
import animation;
animation A;

size(15cm);
currentprojection=orthographic(1,1,1.5);
currentlight=(1,0,1);

triple PXY=-X-Y;
triple P00=PXY+0.5*Z, P03=-X+Y, P33=X+Y, P30=X-Y;

triple[][] P0={
{PXY,PXY+(0,0.5,0),P03+(0,-0.5,0),P03},
{PXY+(0.5,0,0),(-0.5,-0.5,0),(-0.5,0.5,0),P03+(0.5,0,0)},
{P30+(-0.5,0,0),(0.5,-0.5,0),(0.5,0.5,0),P33+(-0.5,0,0)},
{P30,P30+(0,0.5,0),P33+(0,-0.5,0),P33}
};

triple[][][] P1={
{
{PXY,PXY+(0,0.5,0),P03+(0,-0.5,0),P03},
{PXY+(0.5,0,0),(-0.5,-0.5,-2),(-0.5,0.5,-2),P03+(0.5,0,0)},
{P30+(-0.5,0,0),(0.5,-0.5,-2),(0.5,0.5,-2),P33+(-0.5,0,0)},
{P30,P30+(0,0.5,0),P33+(0,-0.5,0),P33}
},
{
{P00,P00+(-0.5,0.5,-1),P03+(0,-0.5,1),P03},
{P00+(0.5,-0.5,-1),(-0.5,-0.5,-2),(-0.5,0.5,-2),P03+(0.5,0,1)},
{P30+(-0.5,0,1),(0.5,-0.5,-2),(0.5,0.5,-2),P33+(-0.5,0,1)},
{P30,P30+(0,0.5,1),P33+(0,-0.5,1),P33}
},
{
{P00,P00+(-0.5,0.5,-1),P03+(0,-0.5,1),P03},
{P00+(0.5,-0.5,-1),(-0.5,-0.5,-2),(-0.5,0.5,2),P03+(0.5,0,1)},
{P30+(-0.5,0,1),(0.5,-0.5,-2),(0.5,0.5,-2),P33+(-0.5,0,1)},
{P30,P30+(0,0.5,1),P33+(0,-0.5,1),P33}
},
{
{P00,P00+(-0.5,0.5,-1),P03+(0,-0.5,1),P03},
{P00+(0.5,-0.5,-1),(-0.5,-0.5,-2),(-0.5,-0.5,2),P03+(0.5,0,1)},
{P30+(-0.5,0,1),(0.5,-0.5,-2),(0.5,0.5,-2),P33+(-0.5,0,1)},
{P30,P30+(0,0.5,1),P33+(0,-0.5,1),P33}
}
};

triple[][] interp(triple[][] a, triple[][] b, real x)
{
triple[][] c;
for (int i=0; i < a.length; ++i) {
triple [] t;
for (int j=0; j < a[i].length; ++j) {
t.push(interp(a[i][j],b[i][j],x));
}
c.push(t);
}
return c;
}

int n=20;
real step=1/n;

for (int i=0; i < P1.length; ++i) {
for (int j=0; j <= n; ++j) {
save();
triple[][] P=interp(P0,P1[i],j*step);
surface s=surface(P);
draw(s,15,15,yellow,meshpen=grey);
draw(sequence(new path3(int i){
return s.s[i].external();},s.s.length), bp+red);

dot("P[0][0]",P[0][0], align=N, black);
dot("P[0][3]",P[0][3], black);
dot("P[3][3]",P[3][3], align=S, black);
dot("P[3][0]",P[3][0], align=W, black);

draw(Label("P[0][1]",align=SW,EndPoint),P[0][0]--P[0][1], Arrow3);
draw(Label("P[1][0]",align=SE,EndPoint),P[0][0]--P[1][0], Arrow3);

draw(Label("P[0][2]",align=E,EndPoint),P[0][3]--P[0][2], Arrow3);
draw(Label("P[1][3]",align=W,EndPoint),P[0][3]--P[1][3], Arrow3);

draw(Label("P[2][3]",align=NE,EndPoint),P[3][3]--P[2][3], Arrow3);
draw(Label("P[3][2]",align=NW,EndPoint),P[3][3]--P[3][2], Arrow3);

draw(Label("P[3][1]",align=NE,EndPoint),P[3][0]--P[3][1], Arrow3);
draw(Label("P[2][0]", align=W,EndPoint),P[3][0]--P[2][0], Arrow3);

dot("P[1][1]",P[1][1], align=N);
dot("P[1][2]",P[1][2], align=E);
dot("P[2][2]",P[2][2], align=N);
dot("P[2][1]",P[2][1], align=W);