使用 Asymptote 的晶体结构标签和角度

使用 Asymptote 的晶体结构标签和角度

我如何表示键之间的角度,并标记几个原子来表示下面链接中绘制的图中的角度?

帮助在 Tikz 中沿路径创建实体圆柱体以绘制晶格图

答案1

在此处输入图片描述

所引用的例子添加了一些标签和一个角度。3D标签放置在label(<TeX-label>,<location>,<alignment>); 例如,label("$\psi$",(1,2.5,0.5),Y-Z);在 处定义一个位置点(1,2.5,0.5),并移动(0,1,-1),因为Y=(0,1,0)Z=(0,0,1)

cr.asy

size(300);
import solids;

currentprojection=orthographic (
camera=(8,5,4),
up=(0,0,1),
target=(2,2,2),
zoom=0.5
);

// save predefined 2D orientation vectors
pair NN=N;
pair SS=S;
pair EE=E;
pair WW=W;

//%points on cube

triple A = (0,0,0);
triple B = (0,0,4);
triple D = (0,4,0);
triple C = (0,4,4);
triple E = (4,0,0);
triple F = (4,0,4);
triple H = (4,4,0);
triple G = (4,4,4);

triple[] cubicCornerA={  
  A,C,F,H,
};

triple[] cubicCornerB={  
  B,D,E,G,
};

label("$A$",A,Y+Z);
label("$B$",B,3Y+3Z);
label("$C$",C,Y+Z);
label("$D$",D,3Y+3Z);
label("$E$",E,3Z-3Y);
label("$F$",F,Z-Y);
label("$G$",G,3Z-2X);
label("$H$",H,Y-Z);

//%center of faces

triple I = (A+B+C+D)/4; //%center of face ABCD
triple J = (E+F+G+H)/4; //%center of face EFGH
triple K = (D+C+G+H)/4; //%center of face DCGH
triple L = (A+B+F+E)/4; //%center of face ABFE
triple M = (C+B+G+F)/4; //%center of face CBGF
triple N = (D+A+E+H)/4; //%center of face DAEH

triple[] faceCenter={  
  I,J,K,L,M,N,
};


//%connectors
triple O = (1,1,3);
triple P = (1,3,1);
triple Q = (3,1,1);
triple R = (3,3,3);

triple[] connectors={  
  O,P,Q,R,
};

label("$O$",O,-4Z);
label("$P$",P,-4Y);
label("$Q$",Q,-4Y);
label("$R$",R,-4Y);

label("$J$",J,4Y);
label("$N$",N,4Y);
label("$L$",L,-4Y);

//write(degrees(dir(Q--E,Q--N)));

//%place non-atom cube corners

real cornerAR=0.05;
real cornerBR=0.2;
real faceCR=0.2;
real connR=faceCR;

pen backPen=gray(0.5)+dashed+1bp;
pen frontPen=gray(0.2)+dashed+1bp;

draw(D--A--B,backPen);
draw(A--E,backPen);

draw(B--C--D,frontPen);
draw(E--F--G--H--cycle,frontPen);
draw(A--E,frontPen);
draw(B--F,frontPen);
draw(C--G,frontPen);
draw(D--H,frontPen);

real cylR=0.062;

void Draw(guide3 g,pen p=currentpen){
  draw(
    cylinder(
      point(g,0),cylR,arclength(g),point(g,1)-point(g,0)
    ).surface(
               new pen(int i, real j){
                 return p;
               }
             )
  );
}

//%connections from faces to O
pen connectPen=lightgray;
Draw(B--O,connectPen);
Draw(I--O,connectPen);
Draw(M--O,connectPen);
Draw(L--O,connectPen);

//%connections from faces to P
Draw(N--P,connectPen);
Draw(I--P,connectPen);
Draw(D--P,connectPen);
Draw(K--P,connectPen);

//%connections from faces to Q
Draw(E--Q,connectPen);
Draw(J--Q,connectPen);
Draw(N--Q,connectPen);
Draw(L--Q,connectPen);

//%connections from faces to R
Draw(G--R,connectPen);
Draw(M--R,connectPen);
Draw(J--R,connectPen);
Draw(K--R,connectPen);

void drawSpheres(triple[] C, real R, pen p=currentpen){
  for(int i=0;i<C.length;++i){
    draw(sphere(C[i],R).surface(
                        new pen(int i, real j){return p;}
                        )
    );
  }
}

drawSpheres(cubicCornerA,cornerAR,lightgray);
drawSpheres(cubicCornerB,cornerBR,darkgray);
drawSpheres(faceCenter,faceCR,red);
drawSpheres(connectors,connR,lightblue);

triple arcBeg=point(Q--E,0.4);
triple arcEnd=point(Q--N,0.4);
triple arcMid=point(Q--(point(E--N,0.5)),0.62);

draw(arcBeg..arcMid..arcEnd, black+1.2pt,Arrows3(size=8pt));

label("$\psi$",arcMid,-Z);

处理asy -f pdf cr.asy以获得一个交互式(Adobe Reader仅)独立的图像cr.pdf,或处理asy -f pdf -noprc -render=0 cr.asy以获得一个普通的图像cr.pdf,或asy -f png -render=5 cr.asy处理以获得一个较小的光栅图像cr.png

相关内容