I was answering a set of problems and found this picture. Since I am just starting to learn about TikZ, I have not been able to draw it.
[Tex/LaTex] Drawing chain with TikZ
asymptotepstrickstikz-pgf
Related Solutions
The trick of my solution is to use a scope
with rotate=45
and then to make all links with |-
. I also define three commands to factorize code.
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows}
\newcommand\reflexive[2]{% node, label
\draw[->] (#1.100) to[reflexive] node[trans,above=-2mm] {#2} (#1.80);
}
\newcommand\link[3]{% start node, end node, label
\draw[edge] (#1) -- (#1 |- #2);
\node[trans] at (#1 |- #2) {#3} (1);
\draw[edge] (#1 |- #2) -- (#2);
}
\newcommand\linkwithdots[4]{% start node, end node, dots node, label
\coordinate (dots1) at (#1 |- #3);
\draw (#1) -- ([yshift=5mm]dots1);
\draw[dotted] ([yshift=5mm]dots1) -- ([yshift=-5mm]dots1);
\draw[edge] ([yshift=-5mm]dots1) -- (#1 |- #2);
\node[trans] at (#1 |- #2) {#4} (1);
\coordinate (dots2) at (#3 |- #2);
\draw (#1 |- #2) -- ([xshift=-5mm]dots2);
\draw[dotted] ([xshift=-5mm]dots2) -- ([xshift=5mm]dots2);
\draw[edge] ([xshift=5mm]dots2) -- (#2);
}
\begin{document}
\begin{tikzpicture}
\tikzset{
>=stealth',
node distance=1.5cm,
state/.style={minimum size=30pt,font=\small,circle,draw},
dots/.style={state,draw=none},
edge/.style={->},
trans/.style={font=\footnotesize,above=2mm},
reflexive/.style={out=120,in=60,looseness=5,relative},
}
\node [state] (0) {$0$};
\node [state] (1) [right of = 0] {$1$};
\node [state] (2) [right of = 1] {$2$};
\node [dots] (d1) [right of = 2] {$\cdots$};
\node [state] (km1) [right of = d1] {$k-1$};
\node [state] (k) [right of = km1] {$k$};
\node [state] (kp1) [right of = k] {$k+1$};
\node [dots] (d2) [right of = kp1] {$\cdots$};
\node [state] (mmk) [right of = d2] {$m-k$};
\node [dots] (d3) [right of = mmk] {$\cdots$};
\node [state] (mm2) [right of = d3] {$m-2$};
\node [state] (mm1) [right of = mm2] {$m-1$};
\begin{scope}[rotate=45]
\reflexive{0}{$\mu_0$}
\reflexive{1}{$\mu_0$}
\reflexive{2}{$\mu_0$}
\link{0}{1}{$\mu_1$}
\link{0}{2}{$\mu_1$}
\link{1}{2}{$\mu_1$}
\linkwithdots{0}{km1}{d1}{$\mu_{k-1}$}
\linkwithdots{1}{km1}{d1}{$\mu_{k-2}$}
\linkwithdots{2}{km1}{d1}{$\mu_{k-3}$}
\end{scope}
\end{tikzpicture}
\end{document}
Now, you have just to complete with some links...
It's quite easy to set up custom axes in TikZ
: for instance, x={(0.707,0.707)}
means that the x-vector points in direction of 45° (up right) with length 1 (in general : (r cos angle,r sin angle)
). I used 45°, 165° and 90° for x, y and z axes. The hard part is imagining what coordinates to use. Another difficulty is the upper part of the left coil: if you draw it via a foreach
loop, then some parts are in front of the front face, while some are behind it, so I used a scope
to restrict the drawing.
\documentclass[parskip]{scrartcl}
\usepackage[margin=15mm]{geometry}
\usepackage{tikz}
\newcommand{\innercolor}{gray!80!black}
\newcommand{\outercolor}{gray!80!white}
\newcommand{\leftcoil}{red!75!gray}
\newcommand{\rightcoil}{green!75!gray}
\pgfmathsetmacro{\coilseparation}{0.02}
\pgfmathsetmacro{\halflinewidth}{0.008}
\begin{document}
\begin{tikzpicture}[x={(0.707cm,0.707cm)},y={(-0.966cm,0.259cm)},z={(0cm,1cm)}]
\filldraw[fill=\innercolor] (0,1,1) -- (1,1,1) -- (1,4,1) -- (0,4,1) -- cycle;
\filldraw[fill=\innercolor] (1,4,1) -- (0,4,1) -- (0,4,4) -- (1,4,4) -- cycle;
\filldraw[fill=\innercolor] (0,0,0) -- (1,0,0) -- (1,0,5) -- (0,0,5) -- cycle;
\filldraw[fill=\innercolor] (0,0,5) -- (0,5,5) -- (1,5,5) -- (1,0,5) -- cycle;
\filldraw[fill=\outercolor,even odd rule] (0,0,0) -- (0,5,0) -- (0,5,5) -- (0,0,5) --cycle (0,1,1) -- (0,4,1) -- (0,4,4) -- (0,1,4) --cycle ;
\begin{scope}
\clip (0,3,1) -- (0,6,1) -- (0,6,4) -- (0,3,4);
\foreach \z in {1.125,1.375,...,3.875}
{ \draw[\leftcoil,thick] (0,5,\z) -- (-\coilseparation,5,\z) -- (-\coilseparation,4-\coilseparation,\z) -- (1+\coilseparation,4-\coilseparation,\z) -- (1+\coilseparation,4,\z);
}
\end{scope}
\foreach \z in {1.25,1.75,...,3.75}
{ \draw[\rightcoil,thick] (0,1,\z) -- (-\coilseparation,1,\z) -- (-\coilseparation,0-\coilseparation,\z) -- (1+\coilseparation,0-\coilseparation,\z) -- (1+\coilseparation,0,\z);
}
\end{tikzpicture}
\end{document}
Edit 1: To help you figure out where you are in 3D, you can append this in the tikzpicture
:
\draw[ultra thick,blue,->] (0,0,0) -- (2.5,0,0) node[below right] {x};
\draw[ultra thick,blue,->] (0,0,0) -- (0,6.5,0) node[below] {y};
\draw[ultra thick,blue,->] (0,0,0) -- (0,0,6.5) node[right] {z};
\foreach \x in {1,2}
{ \draw[ultra thick,blue] (\x,0.1,0) -- (\x,-0.1,0) node[below right] {\x};
}
\foreach \yz in {1,2,3,4,5,6}
{ \draw[ultra thick,blue] (0.1,\yz,0) -- (-0.1,\yz,0) node[below] {\yz};
\draw[ultra thick,blue] (0.1,0,\yz) -- (-0.1,0,\yz) node[right] {\yz};
}
Related Question
- [Tex/LaTex] TIKZ drawing Gaussian Blur
- [Tex/LaTex] Drawing complex diagrams with TikZ using gradients
- [Tex/LaTex] How to draw lemniscate with TikZ
- [Tex/LaTex] Drawing simple graph pattern with Tikz
- [Tex/LaTex] tikz package for drawing thermodynamic cycles
- [Tex/LaTex] Drawing a circle with an angle using TikZ
- [Tex/LaTex] Drawing manifolds in tikz
Best Answer
Clipping, and it needs my
paths.ortho
library.Improvements/Problems
Code
Output