mardi 2 décembre 2014

calculating polar coordinates with tikz


Random polar coordinates has an example of the general sort of syntax I'm aiming to follow. For some reason the result is not working as intended.


In the MWE, I've commented out the line where I would use \MathPunctTwo, since otherwise that gives an error. \MathPunctOne illustrates the sort of output (shown in the figure below) that I'm interested in. \MathPunctTwo should calculate the radius of another point, which would appear on the same ring as the point labelled 3309. But if I uncomment the usage of \MathPunctTwo, pdflatex complains about



"! Missing number, treated as zero."



I'm not familiar with the calc package, so maybe I'm just using that wrong.



\documentclass[10pt]{article}

\usepackage{tikz}
\usetikzlibrary{backgrounds,shapes,arrows,positioning,calc,snakes,fit}
\usepgflibrary{decorations.markings}

\newcommand{\MathPunctOne}[5]{%
\node[dot,label={[label distance=-.1cm]-#5:{\tiny #2}}] (#2) at (-#5:#4cm) {};
}

\newcommand{\MathPunctTwo}[5]{%
\pgfmathsetmacro\radius{{#4 / 7}*5.6}%
\node[dot,label={[label distance=-.1cm]-#5:{\tiny #2}}] (#2) at (-#5:\radius cm) {};
}

\begin{document}

\begin{figure}[htpb]
\centering
\begin{tikzpicture}[>=stealth',join=bevel,font=\sffamily,auto,on grid, decoration={markings, mark=at position .5 with \arrow{>}},dot/.style={circle,inner sep=1pt,fill}]

\MathPunctOne{3305}{3323}{2}{1.6}{72.6605504587156}
\MathPunctOne{3306}{3309}{3}{3.2}{26.422018348623855}
% \MathPunctTwo{3315}{3307}{3}{4}{35}

\draw[black!50] (0,0) circle (5.6cm); % 1
\draw[black!50] (0,0) circle (4.8cm); % 2
\draw[black!50] (0,0) circle (4.0cm); % 3
\draw[black!50] (0,0) circle (3.2cm); % 4
\draw[black!50] (0,0) circle (2.4cm); % 5
\draw[black!50] (0,0) circle (1.6cm); % 6
\draw[black!50] (0,0) circle (0.8cm); % 7

\end{tikzpicture}
\caption{Layer structure}\label{figure:layer structure}
\end{figure}
\end{document}


layers





Aucun commentaire:

Enregistrer un commentaire