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


Asymptote using three.asy – fig0100

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

Figure 0010
(Compiled with Asymptote version 2.14svn-r5318)
    
size(12cm,0);
import bsp;

currentprojection=orthographic(1,1.5,1);

path3 xy=plane((1,0,0),(0,1,0),(0,0,0));
path3 xz=rotate(90,X)*xy;
path3 yz=rotate(-90,Y)*xy;

face[] f;
filldraw(f.push(xy),project(xy),grey);
filldraw(f.push(xz),project(xz),grey);
filldraw(f.push(yz),project(yz),grey);
add(f);

draw(Label("$x$",EndPoint), O--(1,0,0), Arrow3);
draw(Label("$y$",EndPoint), O--(0,1,0), Arrow3);
draw(Label("$z$",EndPoint), O--(0,0,1), Arrow3);
dot(O);

path[] ph=texpath("$\displaystyle\int_{-\infty}^{+\infty}e^{-\alpha x^2}\,dx=
\sqrt{\frac{\pi}{\alpha}}$");
ph =shift((0.5,0.5))*rotate(-45)*scale(1/abs(min(ph)-max(ph)))*ph;

filldraw(project(path3(ph,XYplane)),0.8*yellow);
filldraw(project(path3(ph,ZXplane)),0.8*yellow);
filldraw(project(path3(ph,YZplane)),0.8*yellow);

Étiquettes : , , , , ,


Asymptote using three.asy – fig0110

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

Figure 0011
(Compiled with Asymptote version 2.14svn-r5318)
    
import three;
size(10cm,0);
currentprojection=orthographic(1,1.5,1);

path3 xy=XY*unitsquare3, xz=ZX*unitsquare3, yz=YZ*unitsquare3;

draw(xy^^xz^^yz, grey);
path3 p3xy=path3(texpath("$\pi$")[0],XYplane);
p3xy=shift((0.5,0.5,0))*scale3(1/abs(min(p3xy)-max(p3xy)))*p3xy;

surface s=surface(p3xy,planar=true);
draw(s, surfacepen=blue, meshpen=orange+3pt);

transform3 Txz=planeproject(xz,(0,-1,1));
draw(Txz*s, red);

transform3 Tyz=planeproject(yz,(-1,0,1));
draw(Tyz*s, green);

path3 p3xz=Txz*p3xy;
path3 p3yz=Tyz*p3xy;

int lg=length(p3xy);
triple p;
for(int i=0;i<=lg;++i) {
  p=point(p3xy,i);
  draw(p--point(p3xz,i), yellow);
  draw(p--point(p3yz,i), orange);
}

Étiquettes : , , , ,


Asymptote using solids.asy – fig0040

Category: Asymptote,Examples 3D,solids.asyPh. Ivaldi @ 5 h 56 min

Figure 0004
(Compiled with Asymptote version 2.14svn-r5318)
    
import solids;
size(6cm,0);

currentprojection=orthographic(100,150,30);

real r=1;

skeleton s;
revolution sph=sphere(O,r);
draw(surface(sph), palegray);

path3 cle=rotate(90,X)*scale3(r)*unitcircle3;

triple cam=unit(currentprojection.camera);
real a=degrees(xypart(cam),false)-90;
real b=-sgn(cam.z)*aCos(sqrt(cam.x^2+cam.y^2)/abs(cam));
cle=rotate(b,cross(Z,cam))*rotate(a,Z)*cle;
draw(cle,4pt+red);

Étiquettes : , , , , ,


Asymptote using solids.asy – fig0050

Category: Asymptote,Examples 3D,solids.asyPh. Ivaldi @ 6 h 56 min

Figure 0005
(Compiled with Asymptote version 2.14svn-r5318)
    
import solids;
size(6cm,0);
currentlight=light(diffuse=yellow, ambient=blue, specular=paleyellow,
                   specularfactor=0, viewport=false,(5,-5,10));
// currentprojection=orthographic(100,100,30);
real r=2;

skeleton s;
revolution sph=sphere(O,r);
draw(surface(sph),red);

triple cam=unit(currentprojection.camera);
revolution cle=revolution(O,r*(rotate(90,Z)*cam),cam);
draw(cle, 8pt+black);

Étiquettes : , , , , , ,


Asymptote using solids.asy – fig0060

Category: Asymptote,Examples 3D,solids.asyPh. Ivaldi @ 7 h 56 min

Figure 0006
(Compiled with Asymptote version 2.14svn-r5318)
    
// Author: John Bowman
import three;
size(6cm,0);
currentprojection=perspective(10,100,50);
real a=2.5;

draw(scale3(a)*unitsphere,lightyellow);
draw(align(unit(currentprojection.vector()))*scale3(a)*unitcircle3,2bp+red);

Étiquettes : , , ,


Asymptote using solids.asy – fig0080

Category: Asymptote,Examples 3D,solids.asyPh. Ivaldi @ 9 h 56 min

Figure 0008
(Compiled with Asymptote version 2.14svn-r5318)
    
import solids;
import palette;
size(14cm,0);
currentlight=light(gray(0.4),specularfactor=3,viewport=false,
                   (-0.5,-0.25,0.45),
                   (0.5,-0.5,0.5),(0.5,0.5,0.75));

nslice=4*nslice;
surface s=surface(sphere(O,1));
draw(s,lightgrey);

path3 pl=plane((1,0,0),(0,1,0),(0,0,-1));
surface pls=shift(3,3,-1e-3)*scale(-6,-6,1)*surface(pl);
draw(pls,0.7*red);

real dist(triple z){return abs(z-Z);}

surface shade;
for (int i=0; i < currentlight.position.length; ++i) {
  shade=planeproject(pl,currentlight.position[i])*s;
  draw(shade,mean(palette((shade.map(dist)),
                          Gradient(black,gray(0.6)))),
       nolight);
}

Étiquettes : , , , , , ,


Asymptote using solids.asy – fig0130

Category: Asymptote,Examples 3D,solids.asyPh. Ivaldi @ 14 h 56 min

Figure 0013
(Compiled with Asymptote version 2.14svn-r5318)
    
import solids;
size(8cm,0);
currentprojection=orthographic((2, 1, 2));

revolution r=cylinder((0, 0, 0), 1, -10, X);

draw(r);
draw("$x$",O--X,Arrow3);
draw("$y$",O--Y,Arrow3);
draw("$z$",O--Z,Arrow3);

label(XY()*(scale(2.5)*"This is not a cylinder"), (-5,0,1), align=Z);

Étiquettes : , , , ,


Asymptote using tube.asy – fig0100

Category: Asymptote,Examples 3D,tube.asyPh. Ivaldi @ 4 h 11 min

Figure 0010
(Compiled with Asymptote version 2.14svn-r5318)
    
import tube;
import graph3;
size(12cm,0);
currentprojection=orthographic(4,3,2);

real x(real t) {return sin(t);}
real y(real t) {return cos(t);}
real z(real t) {return sqrt(t);}

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

path section=subpath(unitcircle,0,2);

pen pens(real t){
  return interp(red,blue,t);
}

// Define a transformation wich will be applied to each section at reltime t.
transform T(real t){return scale(t^0.75/2);}

// Combination of pens and transform:
draw(tube(p,coloredpath(section,pens), T));
draw(p);

É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 – pipeintersection

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

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

currentprojection=orthographic(5,4,2);

size(12cm,0);

real f(pair z) {return min(sqrt(1-z.x^2),sqrt(1-z.y^2));}

surface s=surface(f,(0,0),(1,1),40,Spline);

transform3 t=rotate(90,O,Z), t2=t*t, t3=t2*t, i=xscale3(-1)*zscale3(-1);
draw(surface(s,t*s,t2*s,t3*s,i*s,i*t*s,i*t2*s,i*t3*s),blue,
     render(compression=Low,closed=true,merge=true));

Étiquettes : , , ,