Beamer での重なり合う同心多角形

Beamer での重なり合う同心多角形

Beamer正多角形で円の面積を近似するアニメーションを作成したいです。そのためには、同心多角形を重ねる必要があります。アニメーションは重なり合った部分になります。次のコードを試しています。

\documentclass[aspectratio=169,10pt, notheorems]{beamer}
\usepackage{tikz}
\usepackage{pgf}
\usepackage{xcolor}
\usetikzlibrary{shapes.geometric}
\begin{document}
    \begin{frame}
        \begin{figure}
            \begin{tikzpicture}[scale=2]                
                \node [draw, minimum size=3cm, circle] at (0,0) {};
                \foreach \n in {3,...,10}
                \only<+>
                {
                    \node [fill, brown, minimum size=3cm, regular polygon, regular polygon sides=\n] at (0,0) {};
                }
            \end{tikzpicture}
        \end{figure}
    \end{frame} 
\end{document}

コンパイル時にエラーが発生します。部分File ended while scanning use of \pgffor@next.を削除すると\only<+>、コードは正常に実行されます。その場合、アニメーションを取得するにはどうすればよいですか?

追伸:また、各ポリゴンの中心と頂点を結合して、ポリゴン全体を三角形に分割したいと考えています。どうすれば実現できますか? よろしくお願いします。

答え1

試す:

\documentclass[aspectratio=169, notheorems]{beamer}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric}

\begin{document}
\begin{frame}
    \begin{figure}
        \begin{tikzpicture}[scale=2]
            \node [draw, minimum size=3cm, circle] {};
            \foreach \n in {3,...,10}
            { % <-- added
            \only<+>
            {
                \node [fill=brown, minimum size=3cm, 
                       regular polygon, regular polygon sides=\n] {};
            }
            }% <-- added
        \end{tikzpicture}
    \end{figure}
\end{frame}
\end{document}

命令はonly<+>ノードの描画とともにグループ化されている必要があります。つまり、コードに中括弧のペア (グループの定義) がありません。上記の MWE のコメントを参照してください。

編集: 2 番目の質問では、多角形の中心から角まで線を引く新しいループを追加する必要があります。このループを使用して MWE を完成させると次のようになります。

\documentclass[aspectratio=169, notheorems]{beamer}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric}

\begin{document}
\begin{frame}
    \begin{figure}
        \begin{tikzpicture}[scale=2]
            \node [draw, minimum size=3cm, circle] {};
            \foreach \n in {3,...,10}
            {
            \uncover<+> % or \only
            {
                \node (n\n) [fill=brown, minimum size=3cm,
                             regular polygon, regular polygon sides=\n] {};
                \foreach \i in {1,...,\n}      % <--- added
                \draw (0,0) -- (n\n.corner \i);% <--- added
            }
            }
        \end{tikzpicture}
    \end{figure}
\end{frame}
\end{document}

最後のポリゴンの結果は次のようになります。

ここに画像の説明を入力してください

関連情報