在 Latex 中定位

在 Latex 中定位

大家好,我正在尝试删除

\node (ground1) at (0,-5)  [ground, anchor=north] {};

并把

\draw plot[domain=0:3*pi/.9,smooth] (\x,{sin(0.9*\x r)});

另外,无论如何我都可以控制正弦波上的循环次数。谢谢。

请参阅 MWE

\documentclass{article}
\usepackage{graphicx} % to add figure environment that comes with caption
\usepackage{caption} %if you don't want to float your figure for using \captionof
\usepackage{tikz}           
\usetikzlibrary{calc,patterns,decorations.pathmorphing,decorations.markings,circuits}
\begin{document}
\begin{figure}[htbp]
\centering
 \begin{tikzpicture}[every node/.style={draw,outer sep=0pt,thick}]
 \tikzstyle{spring}=[thick,decorate,decoration={zigzag,pre length=0.3cm,post length=0.3cm,segment length=6}]
 \tikzstyle{dampener}=[thick,decoration={markings, mark connection node=dmp,mark=at position 0.5 with {
 \node (dmp) [thick,inner sep=0pt,transform shape,rotate=-90,minimum width=15pt,minimum height=3pt,draw=none] {};
 \draw [thick] ($(dmp.north east)+(2pt,0)$) -- (dmp.south east) -- (dmp.south west) -- ($(dmp.north west)+(2pt,0)$); \draw [thick] ($(dmp.north)+(0,-5pt)$) -- ($(dmp.north)+(0,5pt)$);}}, decorate]
 \tikzstyle{ground}=[fill,pattern=north east lines,draw=none,minimum width=4cm,minimum height=0.3cm]
 \begin{scope}
 \node at (0,0) [draw,rectangle, minimum width=2cm,minimum height=1cm,fill=gray,anchor=south,,transform shape](m1) {$Engine\: mass$};
 \draw [very thick, -latex](m1.east) -- +(1,0)--+(1,1)node[draw=none,midway,right=0.4cm] {y};
 \node at (0,-2) [rectangle, minimum width=4cm,minimum height=1cm,fill=gray,anchor=north,,transform shape](m2) {$Body\: mass$};
 \draw [very thick, -latex](m2.east) -- +(1,0)--+(1,1)node[draw=none,midway,right=0.4cm] {x};
 \draw [spring] (-0.5,-2) -- (-0.5,0) node[draw=none,midway,left=0.3cm] {$3{k}{_R}$};
 \draw [dampener,label=D1,] (0.5,-2) -- (0.5,0)node[draw=none,midway,right=0.4cm] {$3{C}{_R}$};

 \node (ground1) at (0,-5)  [ground, anchor=north] {};
 \draw plot[domain=0:3*pi/.9,smooth] (\x,{sin(0.9*\x r)});
 \draw [spring] (-0.5,-5) -- (-0.5,-3)node[draw=none,midway,left=0.3cm] {$2{k}{_s}{_f}+2{k}{_s}{_r}$};
 \draw [dampener] (0.5,-5) -- (0.5,-3)node[draw=none,midway,right=0.4cm] {$2{C}{_s}{_f}+2{C}{_s}{_r}$};

 \end{scope}
 \end{tikzpicture}
 \caption{2-parameter rubber mount}\label{fig:2-parameter rubber mount}
 \end{figure}
 \end{document}

答案1

你可以用装饰画出你想要的东西:

\documentclass[tikz,border=5mm]{standalone}
\usetikzlibrary{decorations.pathmorphing}
\begin{document}
  \begin{tikzpicture}
    \draw[decoration={snake,segment length=4mm,amplitude=2mm},decorate,fill=white] (-2,0) --
       (2,0);
    \draw[decoration={snake,segment length=3mm,amplitude=2mm},decorate,fill=white] (-2,-1) --
       (2,-1);
    \draw[decoration={snake,segment length=2mm,amplitude=2mm},decorate,fill=white] (-2,-2) --
       (2,-2);
    \draw[decoration={snake,segment length=1mm,amplitude=2mm},decorate,fill=white] (-2,-3) --
       (2,-3);
  \end{tikzpicture}
\end{document}

在此处输入图片描述

您可以调整amplitudesegment length获得所需的波浪数量。

 \documentclass{article}
\usepackage{graphicx} % to add figure environment that comes with caption
\usepackage{caption} %if you don't want to float your figure for using \captionof
\usepackage{tikz}
\usetikzlibrary{calc,patterns,decorations.pathmorphing,decorations.markings,circuits}

\tikzset{
   mysnake/.style={decoration={snake,segment length=4mm,amplitude=2mm},decorate
     },
   spring/.style = {thick,decorate,decoration={zigzag,pre length=0.3cm,post length=0.3cm,
          segment length=6}},
   dampener/.style = {thick,decoration={markings, mark connection node=dmp,mark=at
          position 0.5 with {\node (dmp) [thick,inner sep=0pt,transform shape,rotate=-90,
          minimum width=15pt,minimum height=3pt,draw=none] {};
          \draw [thick] ($(dmp.north east)+(2pt,0)$) -- (dmp.south east) -- (dmp.south west)
          -- ($(dmp.north west)+(2pt,0)$); \draw [thick] ($(dmp.north)+(0,-5pt)$) --
           ($(dmp.north)+(0,5pt)$);}}, decorate},
   ground/.style ={fill,pattern=north east lines,draw=none,minimum width=4cm,minimum
            height=0.3cm}
}
\begin{document}
\begin{figure}[htbp]
\centering
 \begin{tikzpicture}[every node/.style={draw,outer sep=0pt,thick}]
 \begin{scope}
 \node at (0,0) [draw,rectangle, minimum width=2cm,minimum height=1cm,fill=gray,anchor=south,,transform shape](m1) {$Engine\: mass$};
 \draw [very thick, -latex](m1.east) -- +(1,0)--+(1,1)node[draw=none,midway,right=0.4cm] {y};
 \node at (0,-2) [rectangle, minimum width=4cm,minimum height=1cm,fill=gray,anchor=north,,transform shape](m2) {$Body\: mass$};
 \draw [very thick, -latex](m2.east) -- +(1,0)--+(1,1)node[draw=none,midway,right=0.4cm] {x};
 \draw [spring] (-0.5,-2) -- (-0.5,0) node[draw=none,midway,left=0.3cm] {$3{k}{_R}$};
 \draw [dampener,label=D1,] (0.5,-2) -- (0.5,0)node[draw=none,midway,right=0.4cm] {$3{C}{_R}$};

  \draw [spring] (-0.5,-5) -- (-0.5,-3)node[draw=none,midway,left=0.3cm] {$2{k}{_s}{_f}+2{k}{_s}{_r}$};
 \draw [dampener] (0.5,-5) -- (0.5,-3)node[draw=none,midway,right=0.4cm] {$2{C}{_s}{_f}+2{C}{_s}{_r}$};
 %\node (ground1) at (0,-5)  [ground, anchor=north] {};
 %\draw plot[domain=0:3*pi/.9,smooth] (\x,{sin(0.9*\x r)});
 \fill[white]decorate[mysnake]{(-2,-4.8) -- (2,-4.8)} --(2,-5.1) -- (-2,-5.1) -- (-2,-4.8) --cycle;
\draw[mysnake] (-2,-4.8) -- (2,-4.8);
 \end{scope}
 \end{tikzpicture}
 \caption{2-parameter rubber mount}\label{fig:2-parameter rubber mount}
 \end{figure}
 \end{document}

在此处输入图片描述

mysnake为此,我定义了一种新样式,并将所有\tikzstyles 转换为\tikzsets,因为前者已经过时了。

相关内容