如何在 LaTex 中绘制四分之一汽车模型?它基本上是一个双质量和弹簧系统

如何在 LaTex 中绘制四分之一汽车模型?它基本上是一个双质量和弹簧系统

这是我已经写好的代码,但我想让它变得更好,并标记弹簧和阻尼器并画出地面。此外,我需要画出运动的方向,即两个指向上方的质量的 y1 和 y2,我需要为这个模型画出自由体图。如果你能帮我把它弄好看,那将非常有帮助。我很难完成这个,请帮帮我。

    \documentclass{article}
    \usepackage{tikz}
     \usetikzlibrary{calc,patterns,decorations.pathmorphing,decorations.markings}

     \begin{document}

     \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=0.75cm,minimum height=0.3cm]

     \begin{scope}
     \node at (0,0) [draw,name=A,rectangle, minimum width=2cm,minimum height=1cm,anchor=south,,transform shape] {$m1$};
     \node at (0,-2) [name=B,rectangle, minimum width=2cm,minimum height=1cm,anchor=north,,transform shape] {$m2$};
     \draw [spring] (-0.5,-2) -- (-0.5,0) node[left] {k1};
      \draw [dampener] (0.5,-2) -- (0.5,0);
      %\node (ground1) at (-1,-5)  [ground, anchor=north] {};
       \draw [ground] (-1,-5) -- (1,-5);
      \draw [spring] (-0.5,-5) -- (-0.5,-3) ;
       \draw [dampener] (0.5,-5) -- (0.5,-3);

      \end{scope}
        \end{tikzpicture}
       \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}
\begin{document}
Using \verb|graphicx| package:
\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,anchor=south,,transform shape](m1) {$m1$};
      \draw [very thick, -latex](m1.north) -- +(0,1);
     \node at (0,-2) [rectangle, minimum width=2cm,minimum height=1cm,anchor=north,,transform shape](m2) {$m2$};
     \draw [very thick, -latex](m2.north) -- +(0,1);
     \draw [spring] (-0.5,-2) -- (-0.5,0) node[midway,left=0.3cm] {k1};
      \draw [dampener,label=D1,] (0.5,-2) -- (0.5,0)node[midway,right=0.4cm] {d1};
      \node (ground1) at (0,-5)  [ground, anchor=north] {};
%        \draw [ground] (-1,-5) -- (1,-5);
      \draw [spring] (-0.5,-5) -- (-0.5,-3)node[midway,left=0.3cm] {k2};
 %     \draw [spring] (-0.5,-5) -- (-0.5,-3)node[draw=none,midway,left=0.3cm] {k2}; % If you don't want borders around lables use [draw=none]
       \draw [dampener] (0.5,-5) -- (0.5,-3)node[midway,right=0.4cm] {d2};

      \end{scope}
        \end{tikzpicture}
        \caption{My figure}\label{fig:myfigure1}
      \end{figure}

Following will not float, we use \verb|\captionof| from \verb|caption| package. The package \verb|graphicx| not needed for this case.

\begingroup
\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,anchor=south,,transform shape](m1) {$m1$};
      \draw [very thick, -latex](m1.north) -- +(0,1);
     \node at (0,-2) [rectangle, minimum width=2cm,minimum height=1cm,anchor=north,,transform shape](m2) {$m2$};
     \draw [very thick, -latex](m2.north) -- +(0,1);
     \draw [spring] (-0.5,-2) -- (-0.5,0) node[midway,left=0.3cm] {k1};
      \draw [dampener,label=D1,] (0.5,-2) -- (0.5,0)node[midway,right=0.4cm] {d1};
      \node (ground1) at (0,-5)  [ground, anchor=north] {};
%        \draw [ground] (-1,-5) -- (1,-5);
      \draw [spring] (-0.5,-5) -- (-0.5,-3)node[midway,left=0.3cm] {k2};
 %     \draw [spring] (-0.5,-5) -- (-0.5,-3)node[draw=none,midway,left=0.3cm] {k2}; % If you don't want borders around lables use [draw=none]
       \draw [dampener] (0.5,-5) -- (0.5,-3)node[midway,right=0.4cm] {d2};

      \end{scope}
        \end{tikzpicture}
        \captionof{figure}{My figure}\label{fig:myfigure2}
      \endgroup
       \end{document}

在此处输入图片描述

相关内容