점근선 3D가있는 구의 일부

Aug 17 2020

이 그림을 점근선으로 재현하고 싶습니다.

지금까지 구로 할 수 있습니다.

어떻게 구의 일부를 그릴 수 asymptote있습니까?

편집하다

g.kov가 제출 한 답변으로 그림을 재현 할 수있었습니다. 코드는 아래 답변에 있습니다.

답변

9 g.kov Aug 18 2020 at 00:26

힌트

다음과 같은 빌딩 블록에서이 객체를 구성 할 수 있습니다.

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

블록은 예를 들어 다음과 같이 결합 될 수 있습니다.

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

g.kov가 제출 한 답변으로 원하는 모습을 만들 수있었습니다. 다음은 완전한 코드입니다.

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

생성하는 :