我想要画一个简单的图画,一个盒子位于一个倾斜的平面和一个粗糙的水平面上,如下图所示。
我最终从中汲取了灵感,编写了以下代码此链接以及 Zarko 的回答和评论:
\begin{figure}
%Inclined Plane, horizontal plane
\begin{center}
\begin{tikzpicture}[thick]
\def\ang{150}
% Inclined plane
\draw (0,0) coordinate[pos=1.,label={[above=1mm]{B}}] (B) -- ++ (\ang:5) coordinate[label=above left:A] (A) |- (B) coordinate[pos=0.5] (O);
% Angle Theta on the background wrt the inclined plane
\begin{scope}[on background layer]
\pic [draw, thick, -, "$\theta$", angle eccentricity=1.35, fill=gray!30, angle radius=10mm] {angle=A--B--O};
\end{scope}
% Horizontal plane
\draw (B) -- node[below=2mm] {$\mu$} ++ (3,0) coordinate[label=right:C] (aux);
\path [pattern={Lines[angle=45,distance={2pt},
line width=0.1pt]},
pattern color=gray] (B) rectangle ++ (3,-0.2);
% h
\draw (O) -- node[midway,left=2mm] {$h$} (A);
% Mass
\begin{scope}[on background layer]
\node (M) [draw=black,
fill=yellow!60,
minimum width=0.5cm,
minimum height=0.5cm,
anchor=north east,
rotate=\ang,
label=south west:$m$] at (A) {};
\end{scope}
% Speed in A, v_A
\draw[thick, -{Triangle[]}] (M.center) -- ++ (\ang:-1) node[above right] {$\vec{v}_A$};
\end{tikzpicture}
\end{center}
\caption{Setting of problem \ref{prob: inclined_plane_pm_I}.}
\label{fig: inclined_plane_pm_I}
\end{figure}
这对我来说还算不错。我还没有处理H,但我很高兴现在就废除它。
非常感谢 Zarko 和 Jasper。
答案1
编辑:
嗯,坐标A的定位是错误的(不是绝对的应该是相对的......)
像这样?
与您的 MWE 相比,我做了以下更改:
- 使用
arrows.meta
库 - 需要时使用相对坐标
- 角标签写为坐标中的标签
- 顶部的正方形通过使用旋转
rotate around
- 为了好玩,在
C
\documentclass[margin=3mm, varwidth]{standalone}
\usepackage{tikz}
\usetikzlibrary{angles,
decorations.pathmorphing,
calligraphy,% had to be after decorations.pathreplacing
patterns.meta,
quotes}
\begin{document}
\begin{tikzpicture}[
ANG/.style = {draw,
angle radius = 12mm,
angle eccentricity=1.2},
BC/.style args = {#1/#2/#3}{
decorate,
decoration={calligraphic brace, amplitude=6pt,
pre =moveto, pre length=1pt,
post=moveto, post length=1pt,
raise=#1,
#2},% for mirroring of brace
very thick,
pen colour={#3}},
N/.style = {draw, fill=orange!30, minimum size=11mm,
anchor=south west}
]
\def\Ang{150}
\draw[red,pattern={Lines[angle=45,distance={2pt},
line width=0.1pt]},
pattern color=gray]
(3.5,0) coordinate[label=below:B] (b) -- ++ % <---
(\Ang:5) coordinate[label=above left:A] (a) |-
(b) coordinate[pos=0.5, label=below:C] (c);
\pic [ANG, "$\theta$"] {angle = a--b--c};
\pic [draw, angle eccentricity=.5, "$\cdot$"]
{right angle = b--c--a}; % <--- added for fun
%
\draw[BC=8pt/ /teal] (c) -- node[left=4mm] {$h$} (a);
\node[N, rotate around={330:(a)}] at (a) {};
\end{tikzpicture}
\end{document}
编辑: 关于您的评论:
- 对于填充角度轨迹,您只需要添加到
ANG
样式选项fill=<desired color>
。 - 例如
ANG/.style = {draw, fill=gray!30,
angle radius = 12mm,
angle eccentricity=0.75},
为了好玩,还有另一个选择,ANG
在背景上有轨迹(通过保留加粗的三角形边框线):
\documentclass[margin=3mm, varwidth]{standalone}
\usepackage{tikz}
\usetikzlibrary{angles,
backgrounds,
decorations.pathmorphing,
calligraphy,% had to be after decorations.pathreplacing
patterns.meta,
quotes}
\begin{document}
\begin{tikzpicture}[
ANG/.style = {draw, fill=gray!30,
angle radius = 12mm,
angle eccentricity=0.75},
BC/.style args = {#1/#2/#3}{
decorate,
decoration={calligraphic brace, amplitude=6pt,
pre =moveto, pre length=1pt,
post=moveto, post length=1pt,
raise=#1,
#2},% for mirroring of brace
very thick,
pen colour={#3}},
N/.style = {draw, fill=orange!30, minimum size=11mm,
anchor=south west}
]
\def\Ang{150}
\draw[red,pattern={Lines[angle=45,distance={2pt},
line width=0.1pt]},
pattern color=gray]
(3.5,0) coordinate[label=below:B] (b) -- ++ % <---
(\Ang:5) coordinate[label=above left:A] (a) |-
(b) coordinate[pos=0.5, label=below:C] (c);
\scoped[on background layer]
\pic [ANG, "$\theta$"] {angle = a--b--c};
\pic [draw, angle eccentricity=.5, "$\cdot$"]
{right angle = b--c--a}; % <--- added for fun
%
\draw[BC=8pt/ /teal] (c) -- node[left=4mm] {$h$} (a);
\node[N, rotate around={330:(a)}] at (a) {};
\end{tikzpicture}
\end{document}
编辑:
- 您在评论和编辑的问题中提出的问题并不难添加,但可能需要查看
TikZ & PGF manual
。 - 在 Ti 的第三部分钾Z / PGF 手册 (Ti钾是凱恩Zeichenprogramm 描述了您需要了解的所有内容。非常值得一读!
- 关于您的请求,希望以下 MWE 能够满足您的期望:
\documentclass[margin=3mm, varwidth]{standalone}
\usepackage{tikz}
\usetikzlibrary{angles,
backgrounds,
decorations.pathmorphing,
calligraphy,% had to be after decorations.pathreplacing
patterns.meta,
quotes}
\begin{document}
\begin{tikzpicture}[
ANG/.style = {draw, fill=gray!30,
angle radius = 12mm,
angle eccentricity=0.75},
BC/.style args = {#1/#2/#3}{
decorate,
decoration={calligraphic brace, amplitude=6pt,
pre =moveto, pre length=1pt,
post=moveto, post length=1pt,
raise=#1,
#2},% for mirroring of brace
very thick,
pen colour={#3}},
N/.style = {draw, fill=orange!30, minimum size=11mm,
anchor=south west}
]
\def\Ang{150}
\draw[red] (3.5,0) coordinate[label=above right:B] (b) -- ++ % <---
(\Ang:5) coordinate[label=above left:A] (a) |-
(b) coordinate[pos=0.5] (c);
\scoped[on background layer]
\pic [ANG, "$\theta$"] {angle = a--b--c};
\pic [draw, angle eccentricity=.5, "$\cdot$"]
{right angle = b--c--a}; % <--- added for fun
%
\draw[BC=8pt/ /teal] (c) -- node[left=4mm] {$h$} (a);
\node[N, rotate around={330:(a)}] at (a) {};
% new
\draw (b) -- node[below=2mm] {$\mu$} ++ (3,0) coordinate[label=right:$C$] (aux);
\path [pattern={Lines[angle=45,distance={2pt},
line width=0.1pt]},
pattern color=gray] (b) rectangle ++ (3,-0.2);
\end{tikzpicture}
\end{document}