改变 tikz arc 的参数

改变 tikz arc 的参数

为了提供一些背景信息,我正在尝试改编这篇文章的代码

tikz 中的螺旋弹簧

我目前拥有的代码如下

\begin{center}
\begin{tikzpicture}[>=latex,scale=1]
\tikzstyle{spring}=[snake=zigzag,thick,line before snake=0.3cm,line after  snake=0.3cm,segment length=6,segment amplitude=5,join=round]%

\begin{scope}[rotate around={-33:(10,0)}]


\draw[smooth,line width=1pt,fill=black!5] plot coordinates {(0,0)(0.0334,-0.0767)(0.1087,-0.1437)(0.2253,-0.2011)(0.3824,-0.2489)(0.5790,-0.2870)(0.8139,-0.3158)(1.0860,-0.3355)(1.3940,-0.3466)(1.7365,-0.3497)(2.1123,-0.3457)(2.5199,-0.3356) (2.9580,-0.3209)(3.4252,-0.3029)(3.9198,-0.2835)(4.4427,-0.2625)(4.9936,-0.2377)(5.5666,-0.2102)(6.1594,-0.1810)(6.7696,-0.1513)(7.3950,-0.1217)(8.0332,-0.0930)(8.6815,-0.0653)(9.3376,-0.0386)(9.9988,-0.0125)};


\draw[smooth,line width=1pt,fill=black!5] plot coordinates {(0,0)(0.0095,0.0831)(0.0624,0.1691)(0.1590,0.2574)(0.2990,0.3467)(0.4824,0.4357)(0.7085,0.5225)(0.9765,0.6050)(1.2855,0.6812)(1.6341,0.7488)(2.0206,0.8055)(2.4433,0.8492)(2.8998,0.8778)(3.3879,0.8897)(3.9049,0.8833)(4.4459,0.8592)(5.0064,0.8210)(5.5876,0.7687)(6.1870,0.7023)(6.8016,0.6219)(7.4286,0.5277)(8.0650,0.4197)(8.7080,0.2980)(9.3544,0.1623)(10.0012,0.0125)};


\draw[line width=0.5pt,dashed,dash pattern=on 4pt off 1.5pt](-1,0)--(12,0);

\end{scope}%

\begin{scope}[rotate around={-13:(10,0)}]

\draw[line width=0.5pt,dashed,dash pattern=on 4pt off 1.5pt,rotate around={13:(3,0)}](-1,0)--(8,0);

\draw[line width=0.5pt,<-](3,0) +(180:3.5cm) arc (180:193:3.5cm); %This is the line which I am concerned with
\draw(3,0) +(186.5:3.7cm) node{$\alpha$};

\end{scope}

\end{tikzpicture}
\endpgfgraphicnamed%

\end{center}

我想将角度 $\alpha$ 调整为我绘图中的角度。我已经明白,负责该操作的线就是我上面所列出的那条线。

\draw[line width=0.5pt,<-](3,0) +(180:3.5cm) arc (180:193:3.5cm);

如果它没有 $+(180:3.5cm)$ 参数,我可能可以自己处理这个问题。但是,我不明白 $+$ 参数的作用,而且我无法在现有文档中找到有关它的更多信息。

为了获得正确的角度表示,我需要进行哪些更改?

答案1

你喜欢这样的东西吗:

在此处输入图片描述

代码:

\documentclass[border=5mm,
               tikz,
               preview]{standalone}
\usetikzlibrary{angles,intersections,quotes}                % <--- new

    \begin{document}
\begin{tikzpicture}[>=latex,
    spring/.style = {snake=zigzag, thick,line before snake=0.3cm,
                     line after snake=0.3cm, segment length=6,
                     segment amplitude=5, join=round},
      Line/.style = {line width=0.5pt,                      % <--- new
                     dashed,dash pattern=on 4pt off 1.5pt},
        MA/.style = {% My Angle                             % <--- new
                    draw, <-,
                    angle radius = 88mm,
                    angle eccentricity=1,
                    anchor=east}
                    ]%
    \begin{scope}[rotate around={-33:(10,0)}]
\draw[smooth,line width=1pt,fill=black!5] plot coordinates
     {(0,0)            (0.0334,-0.0767) (0.1087,-0.1437) (0.2253,-0.2011)
      (0.3824,-0.2489) (0.5790,-0.2870) (0.8139,-0.3158) (1.0860,-0.3355)
      (1.3940,-0.3466) (1.7365,-0.3497) (2.1123,-0.3457) (2.5199,-0.3356) (2.9580,-0.3209) (3.4252,-0.3029) (3.9198,-0.2835) (4.4427,-0.2625)
      (4.9936,-0.2377) (5.5666,-0.2102) (6.1594,-0.1810) (6.7696,-0.1513)
      (7.3950,-0.1217) (8.0332,-0.0930) (8.6815,-0.0653) (9.3376,-0.0386)
      (9.9988,-0.0125)
%      
     (10.0012,0.0125) (9.3544,0.1623) (8.7080,0.2980) (8.0650,0.4197)
     (7.4286,0.5277)  (6.8016,0.6219) (6.1870,0.7023) (5.5876,0.7687)
     (5.0064,0.8210)  (4.4459,0.8592) (3.9049,0.8833) (3.3879,0.8897)
     (2.8998,0.8778)  (2.4433,0.8492) (2.0206,0.8055) (1.6341,0.7488)
     (1.2855,0.6812)  (0.9765,0.6050) (0.7085,0.5225) (0.4824,0.4357)
     (0.2990,0.3467)  (0.1590,0.2574) (0.0624,0.1691) (0.0095,0.0831)   
     (0,0)};
\draw[Line,name path=L1]                               % <--- added name path
    (-1,0) coordinate (A)                               % <--- added
            -- + (13,0);
    \end{scope}%

\draw[Line, name path=L2]      % <--- added name path
    (-1,1) coordinate (B)                               % <--- added
            -- + (13,0);
\coordinate [name intersections={of=L1 and L2, by=O}];  % <--- new, 
                                                        % determine origin of angle
\pic [MA,"$\alpha$"]     {angle = A--O--B};
\end{tikzpicture}
    \end{document}

编辑:对于角度测量,我建议使用 TikZ 库angles。要使用它,您需要在它们之间定义三个坐标作为角度测量。要确定角度的原点,intersections请使用该库。

我现在也稍微简化了你的代码。看看这种简化是否对你有用。

相关内容