Asymptote using three.asy – fig0050

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

Figure 0005
(Compiled with Asymptote version 2.14svn-r5318)
    
import three; import math;
size(8cm,0);
currentprojection=obliqueX;

real h=2;
triple A =(0,0,h), B=(h,0,0), C=(0,h,0), D=(0,0,0);
triple Ip=midpoint(A--C), J=midpoint(A--B);
triple K=shift((0,0,-0.25*h))*A;

triple M=interp(K,J,intersect(K,J,normal(new triple[]{B,C,D}),D));
triple Np=interp(K,Ip,intersect(K,Ip,normal(new triple[]{B,C,D}),D));

dot("$A$", A, align=Z);  dot("$B$", B, align=S);
dot("$C$", C, align=S);  dot("$D$", D, align=W);
dot("$I$", Ip, align=N); dot("$J$", J, align=W);
dot("$K$", K, align=NE); dot("$M$", M, align=SE);
dot("$N$", Np, align=S);

draw(A--B--C--cycle^^B--M^^C--Np^^J--M^^Ip--Np);
draw(A--D--C^^D--B^^J--K^^K--Ip, dashed);

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

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

Figure 0208
(Compiled with Asymptote version 2.14svn-r5318)
/* This code comes from The Official Asymptote Gallery */
    
import graph3; 
size(400); 
currentlight.background=palegreen;

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

real c=(1+sqrt(5))/2; 
 
triple[] z={(c,1,0),(-c,1,0),(-c,-1,0),(c,-1,0)}; 
triple[] x={(0,c,1),(0,-c,1),(0,-c,-1),(0,c,-1)}; 
triple[] y={(1,0,c),(1,0,-c),(-1,0,-c),(-1,0,c)}; 
 
triple[][] Q={
  {z[0],y[1],x[3],x[0],y[0],z[3]},
  {z[1],x[0],x[3],y[2],z[2],y[3]},
  {z[2],z[1],y[2],x[2],x[1],y[3]},
  {z[3],z[0],y[0],x[1],x[2],y[1]},
  {x[0],x[3],z[1],y[3],y[0],z[0]},
  {x[1],x[2],z[2],y[3],y[0],z[3]},
  {x[2],x[1],z[3],y[1],y[2],z[2]},
  {x[3],x[0],z[0],y[1],y[2],z[1]},
  {y[0],y[3],x[1],z[3],z[0],x[0]},
  {y[1],y[2],x[2],z[3],z[0],x[3]},
  {y[2],y[1],x[3],z[1],z[2],x[2]},
  {y[3],y[0],x[0],z[1],z[2],x[1]} 
}; 
 
path3 p=arc(O,Q[0][0],Q[0][1]); 
real R=abs(point(p,reltime(p,1/3))); 
 
triple[][] P;
for(int i=0; i < Q.length; ++i){
  P[i]=new triple[] ; 
  for(int j=0; j < Q[i].length; ++j){
    P[i][j]=Q[i][j]/R; 
  } 
} 
 
surface sphericaltriangle(triple center, triple A, triple B, triple C,
                          int nu=3, int nv=nu) {
  path3 tri1=arc(center,A,B); 
  path3 tri2=arc(center,A,C); 
  path3 tri3=arc(center,B,C); 
  triple tri(pair p) {
    path3 cr=arc(O,relpoint(tri2,p.x),relpoint(tri3,p.x)); 
    return relpoint(cr,p.y); 
  }; 
 
  return surface(tri,(0,0),(1-sqrtEpsilon,1),nu,nv,Spline); 
} 
 
for(int i=0; i < P.length; ++i){
  triple[] pentagon=sequence(new triple(int k) {
      path3 p=arc(O,P[i][0],P[i][k+1]); 
      return point(p,reltime(p,1/3)); 
    },5); 
  pentagon.cyclic=true; 
  draw(sequence(new path3(int k) {
        return arc(O,pentagon[k],pentagon[k+1]);},5),linewidth(2pt)); 
  triple M=unit(sum(pentagon)/5); 
  for(int i=0; i < 5; ++i){
    surface sf=sphericaltriangle(O,pentagon[i],M,pentagon[i+1]); 
    draw(sf,black); 
  } 
} 
 
for(int i=0; i < P.length; ++i){
  for(int j=1; j <= 5; ++j){
    triple K=P[i][0]; 
    triple A=P[i][j]; 
    triple B=P[i][(j % 5)+1]; 
    path3[] p={arc(O,K,A),arc(O,A,B),arc(O,B,K)}; 
    draw(subpath(p[0],reltime(p[0],1/3),reltime(p[0],2/3)),linewidth(4pt)); 
    triple[] hexagon={point(p[0],reltime(p[0],1/3)),
                      point(p[0],reltime(p[0],2/3)),
                      point(p[1],reltime(p[1],1/3)),
                      point(p[1],reltime(p[1],2/3)),
                      point(p[2],reltime(p[2],1/3)),
                      point(p[2],reltime(p[2],2/3))}; 
    hexagon.cyclic=true; 
    triple M=unit(sum(hexagon)/6); 
    for(int i=0; i < 6; ++i){
      surface sf=sphericaltriangle(O,hexagon[i],M,hexagon[i+1]); 
      draw(sf,white); 
    } 
  } 
}

Étiquettes : , , , , , ,