我正在尝试绘制这幅图:
到目前为止我已经这样做了:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc,patterns,decorations.pathmorphing,decorations.markings}
\begin{document}
\begin{tikzpicture}[>=latex,
every node/.style={ outer sep = 0pt,
thick},
place/.style={ circle,
fill=gray!20,
thick,
inner sep=0pt,
minimum size=6mm}
]
%% Setting a few styles
\tikzstyle{spring}=[decorate,
decoration={zigzag,
pre length=0.3cm,
post length=0.3cm,
segment length=6,
amplitude=6}
]
\tikzstyle{damper}=[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)+(2.5pt,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.3cm,
minimum height=0.3cm]
\tikzstyle{bar}=[fill=lightgray,
draw=black,
minimum width=6cm,
minimum height=0cm,
anchor=west]
%% Drawing start
\node (Bar) [bar, minimum height=0.001cm] at (0,0) {};
\draw[->] (10:2.5) arc[start angle=10, delta angle=-20, radius=3.5] node[anchor=west]{$\theta$};
\node (ground) [ground,anchor=north,minimum height=0.8cm] at ( -0.3,0.4) {};
\node[anchor=east] at (ground.west) {$O$};
\draw (ground.north east) -- (ground.south east);
\draw (0,0) [ fill=lightgray, very thick,domain=-90:90] plot ({cos(\x)/2}, {sin(\x)/2}) --cycle;
\draw [spring] (Bar.north) -- node[anchor=north,xshift=0.5cm]{$k_1$} +(0,2) node(EndSpring1){};
\node (ground1) [ground,anchor=south,minimum width=0.8cm] at (EndSpring1) {};
\draw (ground1.south east) -- (ground1.south west);
\draw [spring] (Bar.east) -- node[anchor=east,xshift=-0.3cm]{$k$} +(0,-2) node(EndSpring){};
\node (m) [bar,anchor=north, minimum height=0.8cm,minimum width=1cm] at (EndSpring) {$m$};
\draw[dash dot] (m.east) -- ($(m.east)+(0.75cm,0)$) node(xaxis){};
\draw[thick,->] (xaxis.center) -- +(0,-1cm)node[near end,anchor=west]{$x$};
\draw[dash dot] (m.south) -- ($(m.south)+(0cm,-0.75)$) node(ldimension1){};
\draw[dash dot] (ground.south east) -- ($(ground.south east)+(0cm,-3)$) node(ldimension2){};
\draw[<->] ($(ldimension1.south)+(0,0.5)$) -- ($(ldimension2.south)+(0,0.5)$) node[midway,anchor=south]{$\ell$};
\draw[dash dot] (Bar.south) -- ($(Bar.south)+(0cm,-2)$) node(adimension){};
\draw[<->] ($(ldimension2.south)+(0,2.5)$) -- ($(adimension.south)+(0,0.5)$) node[midway,anchor=south]{$a$};
\end{tikzpicture}
\end{document}
我得到了这个:
但还存在一个问题:
1.Pin看起来很别扭。
2.尺寸看起来扭曲。
3.Bar好厚啊。
我需要帮助!!!
答案1
以下是我绘制大头针的最佳猜测:外部“物体”看起来不像一个完美的半圆形,它看起来在 x 方向上被拉伸了一点。我们也可以这样做,将其填充为白色,并在其中添加一个小的蓝色圆圈。最后,将地面移近一点,这样它们就会像参考图中那样接触
\node (ground) [ground,anchor=north,minimum height=0.8cm] at ( -0.15,0.4) {};
...
\draw (0,0) [ fill=white, very thick,domain=-90:90] plot ({cos(\x)*8pt}, {sin(\x)*6pt});
\node[circle, draw, fill=blue, inner sep=2pt,anchor=east] at ($(Bar.west)+(6.5pt,0)$) {};
然后,图表看起来是弯曲的,因为测量值a
和l
是歪了。你可以让 TikZ 自己计算坐标来纠正这个问题:定义starta
( 的线的起点),然后让它移动到和 与相交的a
点:starta
ldimension2
starta -| ldimension2
\draw[<->] ($(adimension.south)+(0,0.5)$) coordinate (starta) -- (starta-|ldimension2) node[midway,anchor=south]{$a$};
\draw[<->] ($(ldimension1.south)+(0,0.5)$) coordinate (startl1) -- (startl1-|ldimension2) node[midway,anchor=south]{$\ell$};
关于条形高度:每个节点都有一个参数,即条形内的内容与边框inner sep
之间的距离。即使您的节点为空,并且设置为零,矩形至少也是高度。为了使其更小,我们可以设置为并设置高度{}
minimum height
2*inner sep
inner sep
0pt
确切地和minimum height
:
\tikzstyle{bar}=[fill=lightgray,
draw=black,
minimum width=6cm,
minimum height=0.2cm,
inner sep=0pt,
anchor=west]