Outils du site


wiki:asymptote:exemples:solids

Module solids

Une sphère

On fait ici appel à la commande silhouette pour obtenir le contour circulaire de la sphère.

98b43a2de06dbae17758ba47a6da22a5.png

size(0,4cm);
settings.render = 0;
settings.prc = false;
dotfactor = 3.5;
import solids;
currentprojection = perspective(10,100,25);
real a = 2.5;
triple pO = (0,0,0);
dot(pO);
revolution r = sphere(pO,a);
draw(r.silhouette());
skeleton s;
r.transverse(s,reltime(r.g,0.5),P=currentprojection);
draw(s.transverse.front,solid+blue);
draw(s.transverse.back,dashed+blue);
shipout(bbox(xmargin=1mm,invisible));

Une calotte sphérique

e74f6c824dab111f96f7e7d7d8a21066.png

size(0,4cm);

import solids;
settings.render = 0;
settings.prc = false;
dotfactor = 3.5;

currentprojection = orthographic(5,5,1);
currentlight = nolight;

real a = 1, k = 0.3, h = a*sin(pi*(k-0.5));

// calotte
revolution c = revolution(O,Arc(O,a,180,0,180*(1-k),0,Y),Z);
draw(c,frontpen=lightblue+opacity(.4),backpen=solid+lightblue+opacity(.2));

// sphère
revolution r = sphere(O,a);
draw(r.silhouette());

// équateur
skeleton e;
r.transverse(e,reltime(r.g,0.5),P=currentprojection);
draw(e.transverse.front,solid+black);
draw(e.transverse.back,dashed+black);

// section
skeleton s;
r.transverse(s,reltime(r.g,k),P=currentprojection);
draw(s.transverse.front,solid+blue);
draw(s.transverse.back,dashed+blue);

// points
dot(O);
dot((0,0,h));

shipout(bbox(xmargin=1mm,invisible));

Un cône de révolution

3723f2d296d09d8809b249e98e0ce1f3.png

size(0,4cm);
settings.render = 0;
settings.prc = false;
dotfactor = 3.5;
import solids;
currentprojection = perspective(10,100,25);
real a = 2.5;
real h = 4.5;
triple pO = (0,0,0);
revolution c = cone(pO, a, h, axis=Z, n=1);
draw(c, frontpen=solid+black, backpen=dashed+black);
dot(pO);
shipout(bbox(xmargin=1mm,invisible));

Un cylindre de révolution

1a05ba83d447090c8bbe761f94ed520c.png

size(0,4cm);
settings.render = 0;
settings.prc = false;
dotfactor = 3.5;
import solids;
currentprojection = perspective(10,100,25);
real a = 2.5;
real h = 4.5;
triple pO = (0,0,0);
triple pH = (0,0,h);
revolution c = cylinder(pO, a, h, axis=Z);
draw(c, frontpen=solid+black, backpen=dashed+black);
dot(pO^^pH);
shipout(bbox(xmargin=1mm,invisible));

Fonction draw de solids.asy

Principaux paramètres de la fonction draw.

3bbff60c76edf6889631720394059230.png

import solids;
settings.render = 0;
settings.prc = false;
size(10cm);
currentprojection=orthographic(12,0,1.5);
path3 gene=(0,0,1)--(1,0,0)--(0,0,-1);
revolution bicone=revolution(O,gene,Z,0,360);
draw(bicone, m=0, n=nslice,
	   frontpen=blue, backpen=red,
	   longitudinalpen=.8*green, longitudinalbackpen=magenta+solid,
	   light=currentlight,
           render=defaultrender);
label("longitudinalpen", (10,1.5,2),.8*green);
label("backpen", (10,1.5,1.5),red);
label("frontpen", (10,1.5,1),blue);
label("longitudinalbackpen", (10,1.5,.5),magenta);

Création d'un solide de révolution

Le “château d'eau” est construit à l'aide d'une génératrice. Utilisation d'une macro cote3D pour placer les longueurs.

5ca256df90ae8326e03974c3f3cb6f18.png

import solids;
settings.render=0;
settings.prc=false;
size(8cm);
defaultpen(fontsize(10pt));
dotfactor=3.5;
currentprojection=orthographic(10,0,2);
void cote3D(picture pic=currentpicture,
		Label L="", triple A, triple B, real d=5mm, triple v, bool cc=true,
		pen p=currentpen, pen joinpen=dotted, arrowbar3 arrow=Arrows3){
	transform3 T=shift(d*unit(v));
	triple A=A, B=B;
	pic.add(new void(picture f, transform3 t) {
		picture opic;
		path3 dist;
		triple Ap=t*A, Bp=t*B;
		triple a=T*Ap, b=T*Bp;
		if (cc) {dist=a--b;}
		else {dist=b--a;}
		draw(opic,L,dist,p,arrow);
		draw(opic,a--Ap^^b--Bp,joinpen);
		add(f,opic);
	}, true);
}
transform3 R=rotate(180,Z);
triple O3=(0,0,0), O2=(0,0,6), O1=(0,0,10), pS=(0,0,4),
	G3=(0,2,0), G2=(0,2,6), G1=(0,6,10),
	G12=R*G1, G22=R*G2, G32=R*G3;
path3 gene=G1--G2--G3;  // génératrice
revolution reserve=revolution(O3,gene,axis=Z,0,360);
draw(O1--O3,red+linetype("4 4"));
draw(reserve,linewidth(bp));
draw(surface(reserve),lightgrey+opacity(.2));
draw(G2--pS--G22,bp+linetype("4 4"));
dot("$O_1$",O1,E);dot("$O_2$",O2,NE);dot("$O_3$",O3,NE);
label("$S$",pS,SW);
cote3D("$12$~m",G1,G12,6mm,Z,Arrows3(2mm));
cote3D("$6$~m",G22,G32,-Y,Arrows3(2mm));
cote3D("$4$~m",G32,G3,3mm,-Z,Arrows3(2mm));
cote3D("$6$~m",G1-6Z,G1,Y,Arrows3(2mm));
cote3D("$2$~m",pS+2Y,G2,Y,Arrows3(2mm));
draw(pS+2Y--G1-6Z,dotted);

wiki/asymptote/exemples/solids.txt · Dernière modification: 2017/07/31 17:39 par MB