I want to use variables to store a value in TikZ and do computations based on it. For instance, I want to have variables a,b and c for the following purpose in TikZ:
\draw (a,b) circle (r)
I should be able to assign a,b and c (these can be decimals) and the circle must be drawn at the desired location with the desired radius.
How do I go about doing this?
PS: Essentially, I want to draw 100 small circles inside a unit square at random locations. Hence, I want the variables a, b and c to take random values. Below is my attempt, which doesn't work.
\documentclass{standalone}
\usepackage[first=0, last=1000]{lcg}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\foreach \i in {1,2,...,100}{
\def{a}{\rand\arabic{rand}}
\def{b}{\rand\arabic{rand}}
\draw(a/1000,b/1000) circle (0.001);
}
\end{tikzpicture}
\end{document}
\documentclass{article} \usepackage{tikz} \begin{document} \begin{tikzpicture} \def\a{2} \def\b{3.5} \def\r{1} \draw (\a,\b) circle (\r); \end{tikzpicture} \end{document}– jub0bs May 29 '13 at 04:11\def\a{...}and so on? And then\draw (\a,\b) circle (\r);. – John Wickerson May 29 '13 at 04:11:-)– John Wickerson May 29 '13 at 04:12