Here's an Asymptote solution:
\documentclass{standalone}
\usepackage{asymptote}
\begin{document}
\begin{asy}[width=10cm,height=10cm]
import three;
currentprojection=perspective(300,-650,500,center=true);
// define two types of ions
surface iona = scale3(20)*unitsphere;
surface ionb = scale3(25)*unitsphere;
// surface properties and color of the ions
material White = material(diffusepen=gray(0.4),emissivepen=gray(0.6));
material Red = material(diffusepen=red,emissivepen=lightred);
// style of lines connecting ions
pen thick=linewidth(2);
for(int x=-1; x<2; ++x) {
for(int y=-1; y<2; ++y) {
for(int z=-1; z<2; ++z) {
draw(shift(100*(x,y,z))*iona,White);
}
}
}
for(int x=-1; x<2; ++x) {
for(int y=-1; y<2; ++y) {
for(int z=-1; z<2; ++z) {
if(x<1) draw(100*(x,y,z)--100*(x+1,y,z),thick);
if(y<1) draw(100*(x,y,z)--100*(x,y+1,z),thick);
if(z<1) draw(100*(x,y,z)--100*(x,y,z+1),thick);
}
}
}
for(int x=-1; x<2; x+=2) {
for(int y=-1; y<2; y+=2) {
for(int z=-1; z<2; z+=2) {
draw(shift(50*(x,y,z))*ionb,Red);
}
}
}
\end{asy}
\end{document}
To compile, first run pdflatex
on the file, then asy
on the generated .asy
file, finally pdflatex
once or twice again.
A very simple proof of concept example:
\documentclass{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\draw[fill] (0,0) circle (.5) -- ++(10:2) circle (.5) -- ++(-20:2) circle (.5);
\end{tikzpicture}
\end{document}
Of course one could do some very nice tweaks such as building an own style for the lines and circles, but the code above contains at least everything that is needed to reach your goal.
Depending on what you need exactly, it was also very easily possible to automate the generation of such a chain including for example random angles between the beads.
Here's a version using a \foreach
to specify a list of angles:
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\tikzset{bead/.style={circle,fill=black,inner sep=3pt}}
\draw node[bead] {} (0,0)
\foreach \angle in {10,40,50,-50,0,150,30,-60,45,45,0}
{ -- ++(\angle:1) node[bead] {}};
\end{tikzpicture}
\end{document}
And a version with relative angles (Qrrbrbirlbel suggested this version in chat and I like it more than the one I initially had):
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\tikzset{bead/.style={circle,fill=black,inner sep=3pt}}
\def\angle{0}
\draw node[bead] {} (0,0)
\foreach \stepangle[evaluate=\stepangle as \angle using \angle+\stepangle, remember=\angle] in {10,20,-30,-60,135,-20,-30,0}
{ -- ++(\angle:1) node[bead]{}};
\end{tikzpicture}
\end{document}
Best Answer
Since you included the
asymptote
tag, I assume you will not object to an Asymptote solution:gives the output