我该如何绘制这个钟摆,使钟摆向右移动而不是向左移动?

我该如何绘制这个钟摆,使钟摆向右移动而不是向左移动?

在此处输入图片描述

嗨,有人能帮我画一下这个图吗,但钟摆要向右偏移?我是 LaTeX 新手,所以任何帮助我都非常感谢。

答案1

欢迎来到 TSE。

这是使用 tikz 的解决方案。您可以轻松更改第一个参数。代码中添加了注释。

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows, calc, positioning}

\begin{document}
  \begin{tikzpicture}[>=latex']
    \pgfmathsetmacro\nHoles{9} % defines the number of holes
    \pgfmathsetmacro\dHoles{-1.5} % defines the distance between holes
    \pgfmathsetmacro\pivot{2} % number of the pivot (starting from 1)
    \pgfmathsetmacro\angle{30} % angle of the rotation
    \pgfmathsetmacro\barOffset{10} % offset between holes and bar edges
    \def\lPos{right} % position of the labels L and l
    \pgfmathsetmacro\signL{sign(sin(\angle))} % to determine on which side putting the arrows
    \begin{scope}[rotate around={\angle:(0,\pivot*\dHoles cm)}] % a scope to rotate the bar
      \foreach \H in {1,...,\nHoles} % a loop to draw the holes
      {\draw (0, \H*\dHoles cm) circle [radius=4pt] node (H_\H) {};}
      \draw [very thick, red] (0, \pivot*\dHoles cm) circle [radius=4pt] node (P) {}; % redraw the pivot and name it P
      \draw ($(H_1.center)+(\barOffset pt, \barOffset pt)$) rectangle ($(H_\nHoles.center)-(\barOffset pt, \barOffset pt)$); % draw the bar
      \draw [thin, dotted] ($(H_1)+(0, \barOffset pt)$) --++ (\signL*2 cm, 0);
      \draw [thin, dotted] ($(H_\nHoles)-(0, \barOffset pt)$) --++ (\signL*2cm, 0);
      \draw [<->] ($(H_1)+(\signL*2 cm, \barOffset pt)$) -- ($(H_\nHoles)+(\signL*2 cm, -\barOffset pt)$) node [ \lPos=3pt, pos=.5]  {$L$}; % label L
      \fill ($(H_1)!.5!(H_\nHoles)$) circle [radius=2pt] coordinate (CM); % define the center
      \draw [thin, dotted] (P.center) --++ (\signL*1cm, 0);
      \draw [thin, dotted] (CM.center) --++ (\signL*1cm, 0);
      \draw [<->] ($(P.center)+(\signL*1 cm, 0)$) -- ($(CM)+(\signL*1 cm, 0)$) node [ \lPos=3pt, pos=.5]  {$\ell$}; % label l
    \end{scope} % end of the rotated part
    \node at ($(CM)+(\signL*2*\barOffset pt, 0)$) {$CM$}; % add the CM label
    \draw [dashed] (0,\dHoles) -- (0, \nHoles*\dHoles); % vertical line
    \draw [->] ($(P)+(0, 1.5*\dHoles)$) arc [start angle=90,end angle=90+\angle, radius=1.5*\dHoles cm] node [anchor=north, pos=.5] {$\theta$}; % angle
  \end{tikzpicture}
\end{document}

由此产生了下面的图片。

在此处输入图片描述

相关内容