# defining coordinates in advance in tikz figure

I am trying to create a circle of elements with some randomness to it. I want to predefined the coordinates to create complicated element. I am using this:

\newcommand{\elm}[2]{
\shade [ball color=red] (#1,#2) circle (4 pt);
}


and this:

\begin{tikzpicture}
\foreach \ang in {0,90,...,270}{
\pgfmathsetmacro{\r}{200pt}
\pgfmathsetmacro{\dx}{rand*2}
\pgfmathsetmacro{\dy}{rand*2}
\elm{{\r*cos(\ang) + \dx},{\r*sin(\ang)+\dy}}
}
\end{tikzpicture}


All I get is a blank sheet of paper without any figure. How can do this correctly?

-

It might be more beneficial to use \pgfmathsetlengthmacro for this. Currently it takes 2 meters for the \r variable since the default is centimeters.

\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\foreach \ang in {0,90,...,270}{
\pgfmathsetlengthmacro{\r}{2cm}
\pgfmathsetlengthmacro{\dx}{rand*2 cm}
\pgfmathsetlengthmacro{\dy}{rand*2 cm}
\shade [ball color=red] ({\r*cos(\ang) + \dx},{\r*sin(\ang) + \dy}) circle (4 pt);
}
\end{tikzpicture}
\end{document}


Also if I am not wrong you are passing only one argument to \elm where you have two defined. I removed it to make it more concise.

-