Asymptote using graph3.asy – fig0070

Category: Asymptote,Examples 3D,graph3.asyPh. Ivaldi @ 9 h 11 min

Figure 0007
(Compiled with Asymptote version 2.14svn-r5318)
    
import graph3;

size(8cm,0);
currentprojection=orthographic(1,1,0.5);
limits((-2,-2,0),(0,2,2));

xaxis3(Label("$x$",align=Z),
       Bounds(Min,Min),
       OutTicks(endlabel=false,Step=1,step=0.5));

yaxis3("$y$", Bounds(),
       OutTicks(pTick=0.8*red, ptick=lightgrey));

zaxis3("$z$", Bounds(),
       OutTicks, p=red, arrow=Arrow3);

dot(Label("",align=Z), (-1,0,0), red);

Étiquettes : , ,


Asymptote using three.asy – fig0010

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

Figure 0001
(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 – fig0020

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

Figure 0002
(Compiled with Asymptote version 2.14svn-r5318)
    
import three;
import palette;

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));
s.colors(palette(s.map(zpart),Gradient(yellow,red)));
// s.colors(palette(s.map(zpart),Rainbow()));

draw(s);
draw(sequence(new path3(int i){
      return s.s[i].external();},s.s.length), bp+orange);


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

Étiquettes : , , , , ,


Asymptote using three.asy – fig0030

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

Figure 0003
(Compiled with Asymptote version 2.14svn-r5318)
    
import three;

size(10cm);
currentlight=(0,0,1);

surface sf=surface(patch(P=new triple[][] {
      {(0,0,0),(1,0,0),(1,0,0),(2,0,0)},
      {(0,1,0),(1,0,1),(1,0,1),(2,1,0)},
      {(0,1,0),(1,0,-1),(1,0,-1),(2,1,0)},
      {(0,2,0),(1,2,0),(1,2,0),(2,2,0)}
    }));

draw(sf,surfacepen=yellow);
draw(sf.s[0].vequals(0.5),squarecap+2bp+blue,currentlight);
draw(sf.s[0].uequals(0.5),squarecap+2bp+red,currentlight);

Étiquettes : , , , , ,


Asymptote using three.asy – fig0040

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

Figure 0004
(Compiled with Asymptote version 2.14svn-r5318)
    
import three;
size(8cm,0);
real radius=1, theta=37, phi=60;

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);

triple pQ=radius*dir(theta,phi); // Point Q
// triple pQ=radius*expi(radians(theta),radians(phi)); // Point Q
draw(O--radius*dir(90,phi)^^O--pQ, dashed);
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));

path3 p3=O--arc(O,radius,0,phi,90,phi)--cycle;
draw(surface(p3), blue+opacity(0.5));

Étiquettes : , , , ,


Asymptote using three.asy – fig0090

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

Figure 0009
(Compiled with Asymptote version 2.14svn-r5318)
    
size(10cm,0);
import three;

currentprojection=obliqueX;

triple v1=(4,0,0),
       v2=(0,6,0),
       p0=(-2,-3,0);
path3 pl1=plane(v1,v2,p0);

path ph=transform(v1,v2,p0,currentprojection)*((0,-2){W}..(0,2){W}..cycle);
filldraw(project(pl1)^^ph,evenodd+lightgrey);

Étiquettes : , , , , ,


Official Asymptote example – conicurv

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

Figure 0033
(Compiled with Asymptote version 2.14svn-r5318)
/* This code comes from The Official Asymptote Gallery */
    
// Original name : conicurv.mp 
// Author : L. Nobre G.
// Translators : J. Pienaar (2004) and John Bowman (2005)

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

size(300,0);

currentprojection=perspective(10,-5,5.44); 

real theta=30, width=3, shortradius=2, bord=2, refsize=1, vecsize=2;
real height=0.3, anglar=1.75, totup=3;
real longradius=shortradius+width*Cos(theta), updiff=width*Sin(theta);

triple iplow=(0,shortradius,0), iphig=(0,longradius,updiff);
triple oplow=(-shortradius,0,0), ophig=(-longradius,0,updiff);
triple aplow=-iplow, aphig=(0,-longradius,updiff);
triple eplow=-oplow, ephig=(longradius,0,updiff);
triple anglebase=(0,longradius,0), centre=interp(iplow,iphig,0.5)+(0,0,height);
triple central=(0,0,centre.z), refo=(0,0.5*centre.y,centre.z);
triple refx=refsize*(0,Cos(theta),Sin(theta));
triple refy=refsize*(0,-Sin(theta),Cos(theta));

draw("$\theta$",arc(iplow,iplow+0.58*(iphig-iplow),anglebase),E);

draw(central,linewidth(2bp));
draw(iplow--iphig);
draw(oplow--ophig);
draw(aplow--aphig);
draw(eplow--ephig);
draw(iphig--anglebase--aplow,dashed);
draw(oplow--eplow,dashed);
draw(central--centre,dashed);

draw((0,0,-bord)--(0,longradius+bord,-bord)--(0,longradius+bord,totup)
     --(0,0,totup)--cycle);
draw(Label("$y$",1),refo--refo+refy,SW,Arrow3);
draw(Label("$x$",1),refo--refo+refx,SE,Arrow3);

draw(Label("$\vec{R}_N$",1),centre--centre+vecsize*refy,E,Arrow3);
draw(Label("$\vec{F}_a$",1),centre--centre+vecsize*refx,N,Arrow3);
draw(Label("$\vec{F}_c$",1),centre--centre+vecsize*Y,NE,Arrow3);
draw(Label("$\vec{P}$",1),centre--centre-vecsize*Z,E,Arrow3);
draw(Label("$\vec{v}$",1),centre--centre+vecsize*X,E,Arrow3);
draw(centre,10pt+blue);

draw(circle((0,0,updiff),longradius),linewidth(2bp));
draw(circle(O,shortradius),linewidth(2bp));

Étiquettes : , , ,


Official Asymptote example – cyclohexane

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

Figure 0042
(Compiled with Asymptote version 2.14svn-r5318)
/* This code comes from The Official Asymptote Gallery */
    
import three;

currentprojection=perspective(300,-650,500);
currentlight.background=palecyan;

surface carbon=scale3(70)*unitsphere; // 70 pm
surface hydrogen=scale3(25)*unitsphere; // 25 pm

real alpha=90+aSin(1/3);

real CCbond=156; // 156 pm
real CHbond=110; // 110 pm

triple c1=(0,0,0);
triple h1=c1+CHbond*Z;
triple c2=rotate(alpha,c1,c1+Y)*(CCbond*Z);
triple h2=rotate(120,c1,c2)*h1;
triple h3=c2-CHbond*Z;
triple h4=rotate(120,c2,c1)*h3;

triple c3=rotate(120,c2,h3)*c1;
triple h5=c3+CHbond*Z;
triple h6=rotate(-120,c3,c2)*h5;

triple c4=rotate(-120,c3,h5)*c2;
triple h7=c4-CHbond*Z;
triple h8=rotate(120,c4,c3)*h7;

triple c5=rotate(120,c4,h7)*c3;
triple h9=c5+CHbond*Z;
triple h10=rotate(-120,c5,c4)*h9;

triple c6=rotate(-120,c5,h9)*c4;
triple h11=c6-CHbond*Z;
triple h12=rotate(120,c6,c5)*h11;

pen Black=gray(0.4);

defaultrender=render(compression=Zero,merge=true);

draw(shift(c1)*carbon,Black);
draw(shift(c2)*carbon,Black);
draw(shift(c3)*carbon,Black);
draw(shift(c4)*carbon,Black);
draw(shift(c5)*carbon,Black);
draw(shift(c6)*carbon,Black);


material White=material(diffusepen=gray(0.4),emissivepen=gray(0.6));

draw(shift(h1)*hydrogen,White);
draw(shift(h2)*hydrogen,White);
draw(shift(h3)*hydrogen,White);
draw(shift(h4)*hydrogen,White);
draw(shift(h5)*hydrogen,White);
draw(shift(h6)*hydrogen,White);
draw(shift(h7)*hydrogen,White);
draw(shift(h8)*hydrogen,White);
draw(shift(h9)*hydrogen,White);
draw(shift(h10)*hydrogen,White);
draw(shift(h11)*hydrogen,White);
draw(shift(h12)*hydrogen,White);


pen thick=linewidth(10);

draw(c1--c2--c3--c4--c5--c6--cycle,thick);

draw(c1--h1,thick);
draw(c1--h2,thick);
draw(c2--h3,thick);
draw(c2--h4,thick);
draw(c3--h5,thick);
draw(c3--h6,thick);
draw(c4--h7,thick);
draw(c4--h8,thick);
draw(c5--h9,thick);
draw(c5--h10,thick);
draw(c6--h11,thick);
draw(c6--h12,thick);

Étiquettes : , ,


Official Asymptote example – near_earth

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

Figure 0148
(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);
real radius=0.8, lambda=37, aux=60;

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
triple pQ=radius*dir(lambda,aux);
draw(O--radius*dir(90,aux),dashed);
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);
draw(arc(O,radius*Z,radius*dir(90,aux)),dashed);
draw(arc(O,radius*Z,radius*X),thickp);
draw(arc(O,radius*Z,radius*Y),thickp);
draw(arc(O,radius*X,radius*Y),thickp);

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