如何调试不流畅的动画图像

如何调试不流畅的动画图像

我想创建一个移动三角形的动画(MWE 很难)

所以我有CircleInversion.SimilarTriangles.tex

\documentclass[tikz]{standalone}

\usepackage{tikz}
\usetikzlibrary{calc}

\pgfmathsetmacro{\Pmultiple}{1.6}
\pgfmathsetmacro{\Qmultiple}{0.7}

\begin{document}
    \begin{tikzpicture}
        \def\InvertAPoint(#1){%
            \path let
                \p{PO}=($ (#1)-(O) $),
                \n{distPO}={veclen(\x{PO},\y{PO})},
                \n{Oangle}={atan2(\y{PO}, \x{PO})},
                \n{multiplier}={(\radius * 1cm)^2/\n{distPO}}
                in%
                    ($(O)+(\n{Oangle}:\n{multiplier})$)
                    coordinate (#1Tag);
        }%

        \pgfmathsetmacro{\radius}{2}
        \clip (-\radius, -\radius) rectangle (1.65 * \radius, \radius);

        \pgfmathsetmacro{\pradius}{\Pmultiple * \radius}
        \pgfmathsetmacro{\qradius}{\Qmultiple * \radius}

        \coordinate (O) at (0,0);

        \pgfmathsetmacro{\Pangle}{20}
        \pgfmathsetmacro{\Qangle}{-10}
        \coordinate (P) at (\Pangle:\pradius);
        \coordinate (Q) at (\Qangle:\qradius);

        \draw (O) circle (\radius) node [below] {\small $O$};

        \InvertAPoint(P)
        \InvertAPoint(Q)
        \draw (O) -- (PTag) --(QTag) -- cycle;
        \draw (O) -- (P) -- (Q) -- cycle;

        \draw (PTag) circle (0.8pt)[fill=white] node[above] {$P'$};
        \draw (P) circle (0.8pt)[fill] node [above left] {$P$};
        \draw (QTag) circle (0.8pt)[fill=white] node[below] {$Q'$};
        \draw (Q) circle (0.8pt)[fill] node [below left] {$Q$};

        \node [left] at ($(O)+(120:\radius)$) {$C$};

        \pgfmathsetmacro{\innerradus}{0.17}
        \pgfmathsetmacro{\drawopacity}{0.5}
        \pgfmathsetmacro{\fillopacity}{0.3}

        \foreach \center/\last in { Q/P, PTag/QTag}
        {
            \begin{scope}
                \clip (O) -- (\center) -- (\last) -- cycle;
                \draw[red, fill=red!50, draw opacity=\drawopacity, fill opacity = \fillopacity] 
                    (\center) circle (\innerradus);
            \end{scope}
            \begin{scope}
                \clip (O) -- (\center) -- (\last) -- cycle;
                \draw[blue, fill=blue!50, draw opacity=\drawopacity, fill opacity = \fillopacity]
                    (\last) circle (\innerradus);
            \end{scope}
        }
        \begin{scope}
            \clip (O) -- (P) -- (Q) -- cycle;
            \draw[green, fill=green!50!black, draw opacity=\drawopacity, fill opacity = \fillopacity]
                (O) circle (\innerradus);
        \end{scope}
    \end{tikzpicture}
\end{document}

这段代码可能创建了一些有问题的几何图形。基本上,相对于给定的圆,有两个点反转。

我正在使用上述文件创建动画

\documentclass[pdf]{beamer}
\mode<presentation>{
    \usetheme{Boadilla}
    \usecolortheme{orchid}
}

\usefonttheme{serif}
\setbeamertemplate{headline}{}

\usepackage{standalone}
\usepackage{amsfonts}
\usepackage{animate}
\usepackage{tikz}
\usepackage{pgfplots}
\usepackage{xcolor}
\usepackage[customcolors, beamer]{hf-tikz}%
\usepackage{media9}
\usetikzlibrary{automata,arrows.meta,positioning,calc,angles,through,intersections,patterns,pgfplots.fillbetween}

\usepackage{expl3}
\ExplSyntaxOn
  \cs_set_eq:NN \fpeval \fp_eval:n
\ExplSyntaxOff

\begin{document}
    \begin{frame}{Header}
                \begin{center}
                    \pgfmathtruncatemacro{\PFrames}{20}
                    \pgfmathtruncatemacro{\QFrames}{16}
                    \pgfmathsetmacro{\Pmultiple}{\fpeval{0.6 + \PFrames * 0.05 - 0.05}}
                    \pgfmathsetmacro{\Qmultiple}{\fpeval{0.7 + \QFrames * 0.05 - 0.05}}
                    \begin{animateinline}[autoplay, loop]{4}
                        \multiframe{\PFrames}{nMultiple=0.6+0.05}{%
                            \pgfmathsetmacro{\Pmultiple}{\nMultiple}
                            \pgfmathsetmacro{\Qmultiple}{0.7}
                            \input{CircleInversion.SimilarTriangles}
                        }
                        \newframe
                        \multiframe{\QFrames}{nMultiple=0.7+0.05}{%
                            \pgfmathsetmacro{\Qmultiple}{\nMultiple}
                            \input{CircleInversion.SimilarTriangles}
                        }
                        \newframe               
                        \multiframe{\PFrames}{nMultiple=\Pmultiple+-0.05}{%
                            \pgfmathsetmacro{\Pmultiple}{\nMultiple}
                            \input{CircleInversion.SimilarTriangles}
                        }
                        \newframe               
                        \multiframe{\QFrames}{nMultiple=\Qmultiple+-0.05}{%
                            \pgfmathsetmacro{\Pmultiple}{0.6}
                            \pgfmathsetmacro{\Qmultiple}{\nMultiple}
                            \input{CircleInversion.SimilarTriangles}
                        }
                    \end{animateinline}
                \end{center}
    \end{frame}
\end{document}

Q点开始移动的时候,有两次轻微的震动。这​​让我很难过。

我该如何调试这个问题?我应该看什么?

答案1

代码行

\pgfmathsetmacro{\Pmultiple}{...}

\pgfmathsetmacro{\Qmultiple}{...}

在循环体内部,\multiframe由于未注释行尾,在包含的独立文件前面引入了所谓的“虚假空间”。如果您正确注释掉行尾,虚假空间和图形抖动就会消失:

\pgfmathsetmacro{\Pmultiple}{...}%
\pgfmathsetmacro{\Qmultiple}{...}%

在此处输入图片描述

相关内容