我为一些讲义画过一个图。我确信这不是一个很好的代码。所以我的问题是:是否可以用更好的方法完成,例如使用pgfplots
?
\documentclass[margin=5mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{angles, arrows.meta, calc}
\begin{document}
\begin{tikzpicture}
% coordinate axis
\draw[-latex] (0,0) -- (6,0) node[below left] {$x$};
\draw[-latex] (0,0) -- (0,-6) node[below left] {$y$};
\newcommand{\ang}{-30}
% dashed line
\draw[dashed] (0,0) coordinate (s)-- ++ (\ang:4) coordinate (d1) ;
\draw[-] (d1) --++ (1.7,0) ;
\begin{scope} [rotate=\ang]
\draw [fill = blue!30, draw = black] (d1) rectangle ++ (1,-.6);
\draw[-latex] (d1) --++ (2,0) node[below left] {$V_x$};
\draw[-latex] (d1) --++ (0,-1.5) node[below left] {$V_y$};
\draw[latex-latex] (5.5,0) arc (0:30:1.5) node[below right] {$\varphi$};;
\draw[-latex] (4.8,1) arc (45:-45:1.5) node[below left] {$\omega$};
\end{scope}
\end{tikzpicture}
\end{document}
更新我现在已使用来自@Sebglav 的有用指针更新了代码
\usepackage{tikz}
\usetikzlibrary{angles,quotes, arrows.meta, calc}
\begin{document}
\begin{tikzpicture}
% coordinate axis
\draw[-latex] (0,0) -- (6,0) node[below left] {$x$};
\draw[-latex] (0,0) -- (0,-6) node[below left] {$y$};
\newcommand{\ang}{-30}
% dashed line
\draw[dashed] (0,0) coordinate (s)-- ++ (\ang:4) coordinate (B) ;
\draw[-] (B) --++ (1.7,0) coordinate (C);
\begin{scope} [rotate=\ang]
\draw [fill = blue!30, draw = black] (B) rectangle ++ (1,-.6);
\draw[-latex] (B) --++ (2,0) node[below left] {$V_x$};
\draw[-latex] (B) --++ (0,-1.5) node[below left] {$V_y$};
\draw (5.5,0) coordinate (A) -- (B) -- (C)
pic ["$\varphi$", draw, angle eccentricity=1.2, latex-latex, angle radius=1.5cm] {angle};
\draw[-latex] (4.8,1) arc (45:-45:1.5) node[below left] {$\omega$};
\end{scope}
\end{tikzpicture}
\end{document}```