绘制 3D SrTiO3 结构

绘制 3D SrTiO3 结构

我想通过修改 @strpeter 和 @PatrickT 在第页给出的代码来绘制钛酸锶结构绘制逼真的 3D 晶体结构(钻石)。但不幸的是,Ti 和底部 O 之间的杆没有显示出来。有人能找出问题所在吗?

在此处输入图片描述

\begin{asy}
import three;
settings.render=8;
settings.prc=false;
size(10cm);

//currentprojection=perspective((45,45,30));
currentprojection = orthographic((3,6,1));

material SrCcolor = material(diffusepen=green, ambientpen=gray(0.05), specularpen=white);
material TiCcolor = material(diffusepen=blue, ambientpen=gray(0.1), specularpen=white);
material OCcolor = material(diffusepen=red, ambientpen=gray(0.1), specularpen=white);
material sphereCcolor = material(diffusepen=blue, ambientpen=gray(0.1), specularpen=white);
material cylcolor = material(diffusepen=white, ambientpen=white);

real cylRadius = 0.05;
real sphereRadius = 0.25;
real SrRadius = 0.25;
real TiRadius = 0.2;
real ORadius = 0.1;

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 drawCarbon(triple center) {
     draw(shift(center)*scale3(sphereRadius)*unitsphere, surfacepen=sphereCcolor);
}

void drawSr(triple center) {
     draw(shift(center)*scale3(SrRadius)*unitsphere, surfacepen=SrCcolor);
}

void drawTi(triple center) {
     draw(shift(center)*scale3(TiRadius)*unitsphere, surfacepen=TiCcolor);
}

void drawO(triple center) {
     draw(shift(center)*scale3(ORadius)*unitsphere, surfacepen=OCcolor);
}

triple Aa = (0,0,0);
triple Ab = 4X;
triple Ac = 4Y;
triple Ad = 4X+4Y;
triple Ae = 2X+2Y;
triple Ba = 1X+1Y+1Z;
triple Bb = 3X+3Y+1Z;
triple Ca = 2X+2Z;
triple Cb = 2Y+2Z;
triple Cc = 4X+2Y+2Z;
triple Cd = 2X+4Y+2Z;
triple Da = 3X+1Y+3Z;
triple Db = 1X+3Y+3Z;
triple Ea = 4Z;
triple Eb = 4X+4Z;
triple Ec = 4Y+4Z;
triple Ed = 4X+4Y+4Z;
triple Ee = 2X+2Y+4Z;
triple Fa = 2X+2Y+2Z;

drawO( Ae );
drawO( Ca );
drawO( Cb );
drawO( Cc );
drawO( Cd );
drawO( Ee );

drawTi( Fa );

drawSr( Aa );
drawSr( Ab );
drawSr( Ac );
drawSr( Ad );
drawSr( Ea );
drawSr( Eb );
drawSr( Ec );
drawSr( Ed );

drawRod( Fa, Ae );
drawRod( Fa, Ca );
drawRod( Fa, Cb );
drawRod( Fa, Cc );
drawRod( Fa, Cd );
drawRod( Fa, Ee );

// Frame
//material framecolor = material(diffusepen=white, ambientpen=yellow);
material framecolor = material(diffusepen=white, ambientpen=lightblue);
void drawFrame(triple a, triple b) {
  surface rod = extrude(scale(.5*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=framecolor);
  draw(shift(b)*scale3(cylRadius)*unitsphere, surfacepen=framecolor);
}
drawFrame((0,0,0),4X);
drawFrame((0,0,0),4Y);
drawFrame((0,0,0),4Z);
drawFrame(4X,4X+4Y);
drawFrame(4X,4X+4Z);
drawFrame(4Y,4Y+4X);
drawFrame(4Y,4Y+4Z);
drawFrame(4Z,4X+4Z);
drawFrame(4Z,4Y+4Z);
drawFrame(4X+4Y+4Z,4Y+4Z);
drawFrame(4X+4Z,4X+4Y+4Z);
drawFrame(4X+4Y,4X+4Y+4Z);
\end{asy}

答案1

目前,底部杆与顶部杆处于同一位置。将命令更改drawRod( Fa, Ae );drawRod( Ae, Fa );将解决您的问题。

我没有深入研究你的drawRod功能,但你应该能够改变它,使得点的顺序无关紧要。

在此处输入图片描述

相关内容