Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

How can I denote the angle between the bonds and label a few atoms to denote the angle in the figure drawn in the link below ?

Help creating solid cylinders along a path in Tikz for crystal lattice diagram

share|improve this question

1 Answer 1

up vote 12 down vote accepted

enter image description here

The cited example with some labels and an angle added. 3D-labels are placed with label(<TeX-label>,<location>,<alignment>); For example, label("$\psi$",(1,2.5,0.5),Y-Z); defines a location point at (1,2.5,0.5), and a shift (0,1,-1), since Y=(0,1,0) and 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);

Process with asy -f pdf cr.asy to get an interactive (Adobe Reader only) standalone cr.pdf, or with asy -f pdf -noprc -render=0 cr.asy to get an ordinary cr.pdf, or asy -f png -render=5 cr.asy to get a smaller raster image cr.png.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.