使用渐近线进行粘合

使用渐近线进行粘合

我尝试使用圆柱连接器绘制两种颜色的结合,如下图所示:

在此处输入图片描述

所以我编写了以下代码,但我不知道如何在连接圆柱体中获得双色:

\documentclass{standalone}
\usepackage{asymptote}
\begin{document}
\begin{asy}
import three;
settings.render=8;
settings.prc=false;
size(300);

currentprojection=perspective((45,45,30));

material sphereHfcolor = material(diffusepen=royalblue, gray(0.05), specularpen=white);
material sphereGecolor = material(diffusepen=red, gray(0.05), specularpen=white);
material cylcolor = material(diffusepen=white, black);

real cylRadius = 0.2;
real HfRadius = 0.65;
real GeRadius = 0.55;

void drawRod(triple a, triple b) {
  surface rod = extrude(scale(cylRadius)*unitcircle, axis=length(b-a)*Z);
  triple orthovector = cross(Z, b-a);
  if (length(orthovector) > .01) {
    real angle = aCos(dot(Z, b-a) / length(b-a));
    rod = rotate(angle, orthovector) * rod;
  }
  draw(shift(a)*rod, surfacepen=cylcolor);
}

void drawHf(triple center) {
     draw(shift(center)*scale3(HfRadius)*unitsphere, surfacepen=sphereHfcolor);
}

void drawGe(triple center) {
     draw(shift(center)*scale3(GeRadius)*unitsphere, surfacepen=sphereGecolor);
}
triple Cd = 2X+1.15Y+14.74Z;
triple Fb = 4X+12.75Z;
drawRod(Fb,Cd);
drawHf(Cd);
drawGe(Fb);
\end{asy}
\end{document}

相关内容