在机械图示中在倾斜的平面上绘制两个盒子

在机械图示中在倾斜的平面上绘制两个盒子

考虑:

在此处输入图片描述

我需要帮助来绘制倾斜的两个盒子。

\documentclass{standalone}
\usepackage{tikz}

\begin{document}

\begin{tikzpicture}
\draw (2,3) coordinate (A) - - (8,0) coordinate (B)
- - (2,0) coordinate (C) pic [draw,->] {angle};
\fill[pattern=north west lines](2,-1) rectangle(9,0);
    \draw(7,.2 5) node[left] {$\theta$};
    \end{tikzpicture}
\end{document}

答案1

绘制两个倾斜框的一种方法是使用scope带有rotate应用的:

在此处输入图片描述

代码:

\documentclass[border=1pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{patterns}

\begin{document}

\begin{tikzpicture}
\draw  (2,3) coordinate (A) 
    -- (8,0) coordinate (B)
    -- (2,0) coordinate (C) 
    -- cycle;
\fill[pattern=north west lines]
    (2,-1) rectangle(8,0);
    \draw(7,.2 5) node[left] {$\theta$};
    
\begin{scope}[rotate=atan((3-0)/(2-8))]
    \draw  [fill=cyan!40, densely dashed] ([shift={(-0.5,0)}]A) rectangle ++(1,0.5);
    \draw  [fill=red!20]                  ([shift={(-0.5,0)}]B) rectangle ++(1,0.5);
\end{scope}
\end{tikzpicture}
\end{document}

答案2

\documentclass[border = 5pt]{standalone}

\usepackage{tikz}
\usetikzlibrary{patterns, calc, quotes, angles}

\def\inc{25}

\begin{document}
\begin{tikzpicture}

  % incline
  \draw (0,0) coordinate(O) -- (180-\inc : 7) coordinate(A) |- coordinate (D) ($(O)+(0,-1)$) -- cycle;
  \draw[dashed] (O) -| coordinate (C) (A);
  \fill[pattern = north west lines] (D) rectangle (O);

  % measures
  \draw[|<->|] ($(A)+(-0.5, 0)$) -- ($(C)+(-0.5, 0)$) node[midway, left]{$h$};
  \pic["$\theta$", <->, draw, angle eccentricity = 1.2, angle radius = 1cm] {angle = A--O--C};


  % block
  \begin{scope}[rotate=180-\inc]
    \draw[shift={(A)}, dashed] ($(A)+(-0.4,0)$) rectangle ++ (0.8,-0.6);
    \draw (-0.4, 0) rectangle ++ (0.8,-0.6);
    \draw[-latex] (0.4, -1) -- (-0.4, -1) node[above, midway]{${\bf v}$};
  \end{scope}
\end{tikzpicture}
\end{document}

在此处输入图片描述

加上一点动画

\documentclass[border = 5pt, tikz]{standalone}

\usepackage{tikz}
\usetikzlibrary{patterns, calc, quotes, angles}

\begin{document}

\foreach \inc in {60,58,...,20,22,24,...,60}
{
  \begin{tikzpicture}
    \useasboundingbox (-8, -1.5) rectangle (1, 6);

    % incline
    \draw (0,0) coordinate(O) -- (180-\inc : 7) coordinate(A) |- coordinate (D) ($(O)+(0,-1)$) -- cycle;
    \draw[dashed] (O) -| coordinate (C) (A);
    \fill[pattern = north west lines] (D) rectangle (O);

    % measures
    \draw[|<->|] ($(A)+(-0.5, 0)$) -- ($(C)+(-0.5, 0)$) node[midway, left]{$h$};
    \pic["$\theta$", <->, draw, angle eccentricity = 1.2, angle radius = 1cm] {angle = A--O--C};


    % block
    \begin{scope}[rotate=180-\inc]
      \draw[shift={(A)}, dashed] ($(A)+(-0.4,0)$) rectangle ++ (0.8,-0.6);
      \draw (-0.4, 0) rectangle ++ (0.8,-0.6);
      \draw[-latex] (0.4, -1) -- (-0.4, -1) node[above, midway]{${\bf v}$};
    \end{scope}
  \end{tikzpicture}
}
\end{document}

在此处输入图片描述

答案3

PSTricks 解决方案仅用于娱乐目的。

\documentclass[pstricks,12pt]{standalone}
\usepackage{pst-eucl}
\begin{document}
\pspicture(-1,-1)(8,5)
    \psframe[fillstyle=vlines,hatchsep=1pt,linestyle=none](0,-.5)(7,0)
    \pstTriangle[PointName=none,PointSymbol=none](0,0){A}(7,0){B}(0,4){C}
    \pstMarkAngle{C}{B}{A}{$\theta$}
    \pcline(C)(B)\naput[npos=-.05,labelsep=-\pslinewidth,nrot=:U]{\psframe(1,.5)\psframe(8,0)(9,.5)\pcline{->}(8.25,.75)(8.75,.75)\naput[labelsep=12pt]{\rput{*0}{$\vec{v}$}}}
    \pcline[offset=10pt]{|*-|*}(A)(C)\naput{$h$}
\endpspicture
\end{document}

在此处输入图片描述

答案4

无需计算任何旋转,您可以decorations.markings使用transform shape

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{patterns,   angles, quotes}
\usetikzlibrary{decorations.markings, arrows.meta, positioning} 
\tikzset{mynode/.style={
    inner sep=0pt,
    text width=1cm,
    minimum height=.5cm,
    transform shape, draw, anchor=south}}

\begin{document}
\begin{tikzpicture}[>=Stealth]
\draw (2,3) coordinate (A) -- (8,0) coordinate (B) 
    -- (2,0) coordinate (C) pic ["$\theta$"'above left=-4pt and 12pt, draw, ->, angle radius=28pt] {angle}  -- cycle;

\path [decorate,
    decoration={
    markings,% switch on markings
    mark=at position 0 with {\node[mynode, dashed]{};},
    mark=at position 1 with {\node[mynode](V){};
    \draw[->] ([yshift=4pt]V.north west) node[above=20pt,transform shape, midway] {$v$} -- ([yshift=4pt]V.north east);}}
    ]
    (A) -- (B);

\fill[pattern=north west lines](C) rectangle ++(6,-1);

\draw[<->] ([xshift=-4pt]A) -- node[left] {$h$} ([xshift=-4pt]C);
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容