6

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:

enter image description here

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)'.

0

2 Answers 2

8

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}

enter image description here

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}

enter image description here

2
  • I do appreciate your help, sir.
    – user78499
    Oct 26, 2019 at 22:49
  • 1
    @Roboticist My pleasure!
    – user194703
    Oct 26, 2019 at 23:35
6

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);
1
  • 1
    Nice to see here the coauthor of Asymptote!
    – Black Mild
    Oct 27, 2019 at 3:25

You must log in to answer this question.