Tikz 坐标定位

Tikz 坐标定位

大家好,我正在尝试合并 2 个对象,之前有人帮助我实现了这个目标。我教过这应该很容易,但事实并非如此。请参阅附件。我的梦想是右边的图形,而我试图插入的是左边的对象。代码是针对我想要插入对象的绘制对象。在此处输入图片描述不清楚的部分是我试图将其插入的地方(如果不清楚,请原谅)。

\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=8.7mm,amplitude=1.5mm},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},
 }
\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 [line width=0.8pt] ($(wall.north west)!0.2!(wall.north east)$) -- ++(0,2cm)coordinate (z);
\draw [spring]   (z) -- ++(0,2cm)coordinate (u) node[draw=none,midway,right=0.1cm] {${k}{_1}$}; 
\draw [line width=0.8pt] (u) -- ($(walle.south west)!0.2!(walle.south east)$);

\draw [line width=0.8pt]   ($(walle.south west)!0.8!(walle.south east)$) -- ++(0,-1cm)coordinate (w);
\draw [spring] (w) -- ++(0,-2cm)coordinate (t) node[draw=none,midway,right=0.1cm] {${k}{_2}$}; 

\coordinate (upperright) at ( $ (t)+(0.5,0) $ ); 
\coordinate (lowerleft) at ( $ (t)+(-0.5,-2) $ ); 

\draw (lowerleft) -- (lowerleft-|upperright);
\draw (upperright) -- (lowerleft|-upperright);
\draw [damper,label=D1,](lowerleft|-upperright) -- (lowerleft)  node[draw=none,midway,left=0.3cm] {${\eta}$};
\draw [spring] (upperright) -- (lowerleft-|upperright)  node[draw=none,midway,right=0.1cm] {${k}{_3}$};

\draw [line width=0.8pt] ($(wall.north west)!0.8!(wall.north east)$) -- (t|-lowerleft);








  \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}$};
 \fill[red]decorate[mysnake]{(-2,-4.8) -- (2,-4.8)} --(2,-5.2) -- (-2,-5.2) -- (-2,-4.8) --cycle;
\draw[mysnake] (-2,-4.8) -- (2,-4.8)node at (2.5,-5.1)[draw=none,left=(4.8cm)] {$x_{o}{t}{=}{X_o}{sin}({2}{\pi}{f}{t})$};
 \end{scope}
 \end{tikzpicture}
 \caption{2-parameter rubber mount}\label{fig:3-parameter rubber mount}
 \end{figure}
 \end{document}

答案1

希望我明白你的意思...

\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=8.7mm,amplitude=1.5mm},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},
 }
\begin{document}
\begin{figure}[htbp]
\centering
 \begin{tikzpicture}[every node/.style={draw,outer sep=0pt,thick}]
 \begin{scope}
 \node at (0,3) [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,-1.7) [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 [line width=0.8pt] ($(m1.south west)!0.2!(m1.south east)$) -- ++(0,-1.5cm)coordinate (z);
\draw [spring]   (z) -- ++(0,-2cm)coordinate (u) node[draw=none,midway,left=0.1cm] {${k}{_1}$};
\draw [line width=0.8pt] (u) -- (u|-m2.north);

\draw [line width=0.8pt]   ($(m1.south west)!0.8!(m1.south east)$) -- ++(0,-0.05cm)coordinate (w);
\draw [spring] (w) -- ++(0,-1.5cm)coordinate (t) node[draw=none,midway,right=0.1cm] {${k}{_2}$};

\coordinate (upperright) at ( $ (t)+(0.5,0) $ );
\coordinate (lowerleft) at ( $ (t)+(-0.5,-2) $ );

\draw (lowerleft) -- (lowerleft-|upperright)coordinate[pos=0.5] (aa);
\draw (upperright) -- (lowerleft|-upperright);
\draw [dampener,label=D1,](lowerleft|-upperright) -- (lowerleft)  node[draw=none,midway,left=0.3cm] {${\eta}$};
\draw [spring] (upperright) -- (lowerleft-|upperright)  node[draw=none,midway,right=0.1cm] {${k}{_3}$};

\draw [line width=0.8pt] (aa|-m2.north) -- (t|-lowerleft);


  \draw [spring] ($(m2.south west)!0.4!(m2.south east)$) -- +(0,-2.3)node[draw=none,midway,left=0.3cm] {$2{k}{_s}{_f}+2{k}{_s}{_r}$};
 \draw [dampener] ($(m2.south west)!0.6!(m2.south east)$) -- +(0,-2.3)node[draw=none,midway,right=0.4cm] {$2{C}{_s}{_f}+2{C}{_s}{_r}$};
 \fill[red]decorate[mysnake]{(-2,-4.8) -- (2,-4.8)} --(2,-5.2) -- (-2,-5.2) -- (-2,-4.8) --cycle;
\draw[mysnake] (-2,-4.8) -- (2,-4.8)node at (2.5,-5.1)[draw=none,left=(4.8cm)] {$x_{o}{t}{=}{X_o}{sin}({2}{\pi}{f}{t})$};
 \end{scope}
 \end{tikzpicture}
 \caption{2-parameter rubber mount}\label{fig:3-parameter rubber mount}
 \end{figure}
 \end{document}

在此处输入图片描述

相关内容