Partie de sphère avec asymptote 3D

Aug 17 2020

Je voudrais reproduire cette image avec asymptote:

Jusqu'à présent, je peux le faire avec la sphère:

Comment puis-je dessiner la partie de la sphère en utilisant asymptote?

Éditer

J'ai pu reproduire l'image avec la réponse soumise par g.kov. Le code est dans la réponse ci-dessous.

Réponses

9 g.kov Aug 18 2020 at 00:26

Allusion

Vous pouvez essayer de construire cet objet à partir de blocs de construction comme celui-ci:

import graph3;
size(200,0);
currentprojection=orthographic(camera=(-24,-30,-70),
   up=Z,target=Z-Z,zoom=0.9,viewportshift=(0.02,0.02));
real R=1;
triple fs(pair u){
  real phi=u.x, theta=u.y;
  return R*(cos(theta)*cos(phi),cos(theta)*sin(phi),sin(theta));
}
surface qXYZ=surface(fs,(0,0),(pi/2,pi/2),nu=8,nv=100,usplinetype=Spline);
surface qXY=surface((0,0,0)--arc((0,0,0),(R,0,0),(0,R,0))--cycle);
surface qXZ=surface((0,0,0)--arc((0,0,0),(R,0,0),(0,0,R))--cycle);
surface qYZ=surface((0,0,0)--arc((0,0,0),(0,R,0),(0,0,R))--cycle);
surface[] s={qXYZ,qXY,qXZ,qYZ};
draw(s,lightgray,meshpen=nullpen,render(merge=true));

Les blocs peuvent être combinés, par exemple, comme ceci:

import graph3;
size(200,0);
currentprojection=
  orthographic(camera=(-34,27,-67),up=Y,target=Z-Z,zoom=0.6,viewportshift=(0.01,0.01));
real R=1;
real a=2*R/sqrt(2);
triple fs(pair u){
  real phi=u.x, theta=u.y;
  return R*(cos(theta)*cos(phi),cos(theta)*sin(phi),sin(theta));
}

surface sXYZ=surface(fs,(0,0),(2pi,pi/2),nu=8,nv=100,usplinetype=Spline);
surface sXY=surface(circle((0,0,0),R));

surface qXYZ=surface(fs,(0,0),(pi/2,pi/2),nu=8,nv=100,usplinetype=Spline);
surface qXY=surface((0,0,0)--arc((0,0,0),(R,0,0),(0,R,0))--cycle);
surface qXZ=surface((0,0,0)--arc((0,0,0),(R,0,0),(0,0,R))--cycle);
surface qYZ=surface((0,0,0)--arc((0,0,0),(0,R,0),(0,0,R))--cycle);

surface[] s={sXYZ,sXY};
surface[] q={qXYZ,qXY,qXZ,qYZ};

for(int i=0;i<4;++i)
  draw(rotate(i*90,X)*shift((0,0,-a))*s,orange,meshpen=nullpen,render(merge=true));

draw(rotate(( 90),Y)*shift((0,0,-a))*s,orange,meshpen=nullpen,render(merge=true));
draw(rotate((-90),Y)*shift((0,0,-a))*s,orange,meshpen=nullpen,render(merge=true));

draw(shift((-a,-a,-a))*q,red,meshpen=nullpen,render(merge=true));
draw(shift(( a,-a,-a))*rotate(90,Z)*q,deepgreen,meshpen=nullpen,render(merge=true));
draw(shift(( a, a,-a))*rotate(180,Z)*q,blue,meshpen=nullpen,render(merge=true));
draw(shift((-a, a,-a))*rotate(270,Z)*q,lightgray,meshpen=nullpen,render(merge=true));

transform3 tr=reflect(Z-Z,X,Y);

draw(tr*shift((-a,-a,-a))*q,red,meshpen=nullpen,render(merge=true));
draw(tr*shift(( a,-a,-a))*rotate(90,Z)*q,deepgreen,meshpen=nullpen,render(merge=true));
draw(tr*shift(( a, a,-a))*rotate(180,Z)*q,blue,meshpen=nullpen,render(merge=true));
draw(tr*shift((-a, a,-a))*rotate(270,Z)*q,lightgray,meshpen=nullpen,render(merge=true));
1 Fabien Aug 19 2020 at 15:47

Avec la réponse soumise par g.kov, j'ai pu produire le chiffre que je voulais. Voici le code complet:

import graph3;
size(200,0);
currentprojection=  orthographic(camera=(-34,27,-67),up=Y,target=Z-,zoom=0.6,viewportshift=(0.01,0.01));
real R=1.5;
real a=2*R/sqrt(2);
triple fs(pair u){real phi=u.x, theta=u.y;return R*(cos(theta)*cos(phi),cos(theta)*sin(phi),sin(theta));}
xaxis3("$x$",0,1,red);
yaxis3("$y$",0,1,deepgreen);
zaxis3("$z$",0,1,blue);
surface sXYZ=surface(fs,(0,0)(2pi,pi/2),nu=8,nv=100,usplinetype=Spline);
surface sXY=surface(circle((0,0,0),R));

surface qXYZ=surface(fs,(0,0),(pi/2,p/2),nu=8,nv=100,usplinetype=Spline);
surface qXY=surface((0,0,0)--arc((0,0,0),(R,0,0),(0,R,0))--cycle);
surface qXZ=surface((0,0,0)--arc((0,0,0),(R,0,0),(0,0,R))--cycle);
surface qYZ=surface((0,0,0)--arc((0,0,0),(0,R,0),(0,0,R))--cycle);

surface[] s={sXYZ,sXY};
surface[] q={qXYZ,qXY,qXZ,qYZ};

draw(shift((0,0,-a))*s,blue,meshpen=nullpen,render(merge=true));
draw(rotate((90),X)*shift((0,0,a))*s,blue,meshpen=nullpen,render(merge=true));
draw(rotate((180),X)*shift((0,0,a))*s,blue,meshpen=nullpen,render(merge=true));
draw(rotate((270),X)*shift((0,0,a))*s,blue,meshpen=nullpen,render(merge=true));
draw(rotate((90),Y)*shift((0,0,a))*s,blue,meshpen=nullpen,render(merge=true));
draw(rotate((-90),Y)*shift((0,0,-a))*s,blue,meshpen=nullpen,render(merge=true));
draw(shift((-a,-a,-a))*q,blue,meshpen=nullpen,render(merge=true));
draw(shift(( a,-a,a))*rotate(90,Z)*q,blue,meshpen=nullpen,render(merge=true));
draw(shift(( a, a,a))*rotate(180,Z)*q,blue,meshpen=nullpen,render(merge=true));
draw(shift((-a, a,-a))*rotate(270,Z)*q,blue,meshpen=nullpen,render(merge=true));

draw(shift((-a,-a,a))*rotate(90,Y)*q,blue,meshpen=nullpen,render(merge=true));
draw(shift(( a,-,a))*rotate(90,Z)*rotate(90,Y)*q,blue,meshpen=nullpen,render(merge=true));
draw(shift((-a,a,a))*rotate(270,Z)*rotate(90,Y)*q,blue,meshpen=nullpen,render(merge=true));
draw(shift(( a,a,a))*rotate(180,Z)*rotate(90,Y)*q,blue,meshpen=nullpen,render(merge=true));

draw((-a,-a,-a)--( a,-a,-a)--( a, a,-a)--(-a, a,-a)--cycle,linewidth(2));
draw((-a,-a,a)--( a,-a,a)--( a, a,a)--(-a, a,a)--cycle,linewidth(2));
draw((a,-a,-a)--( a,-a,a),linewidth(2));
draw((a,a,-a)--( a,a,a),linewidth(2));
draw((-a,-a,-a)--( -a,-a,a),linewidth(2));
draw((-a,a,-a)--( -a,a,a),linewidth(2));

qui produisent: