# How to rotate with respect to a specific point in Asymptote?

The page 47 of the Asymptote manual says that the rotate command "rotates by angle in degrees about z" as follows:

transform rotate(real angle, pair z=(0,0));

I'd like to exploit this feature to arrange n circles around a hypothetical reference point such that each circle is a rotated version of its adjacent peer with respect to that point by theta degrees. The result would visually be something like:

Here is what I have tried.

\documentclass{article}
\usepackage{asymptote}

\begin{document}
\begin{asy}
size(5cm);
path p = circle((0,3),1);
for(int i=0; i<=10; ++i)
{
draw(
p*rotate(
(i*pi/18),(0,0)
)
);
}
\end{asy}

\end{document}


However, compilation yields: *no matching function 'operator (path, transform)'.

According to what I find it suffices to change the order. (I hope you do not mind me switching to ayspictureB, you only need to compile with pdflatex -shell-escape.)

\documentclass{article}
\usepackage{asypictureB}

\begin{document}
\begin{asypicture}{name=robo}
size(5cm);
path p = circle((0,3),1);
for(int i=0; i<=10; ++i)
{
draw(
rotate(
(i*pi/18),(0,0)
)*p
);
}
\end{asypicture}

\end{document}


In order to arrive at something reminiscent of your screen shot, supply units. (It appears to me that otherwise the units are taken to be pt, and the angle conventions seem to be as unfortunate as in TikZ, even though I thought this was not the case. At least if I use degrees, the result is consistent.)

\documentclass{article}
\usepackage{asypictureB}

\begin{document}
\begin{asypicture}{name=robo}
size(5cm);
path p = circle((0,3cm),1cm);
for(int i=0; i<=10; ++i)
{
draw(
rotate(
(i*10),(0,0)
)*p
);
}
\end{asypicture}

\end{document}


• I do appreciate your help, sir. – Roboticist Oct 26 '19 at 22:49
• @Roboticist My pleasure! – Schrödinger's cat Oct 26 '19 at 23:35

You don't actually need asypictureB (or the more modern asymptote.sty package) or even the LaTeX commands if you run this example directly with asy.

The point of specifying size(5cm); is so you don't have to specify the units. You can instead specify unitsize(1cm); if you are working in cm. Here is a simplified version, rotating through 9 increments each of 10 degrees:

size(5cm);
path p=circle((0,3),1);
for(int i=0; i < 10; ++i)
draw(rotate((i*10),(0,0))*p);

• Nice to see here the coauthor of Asymptote! – Black Mild Oct 27 '19 at 3:25