我想画一个圆锥摆。
使用此代码:
\documentclass[a4paper]{article}
\usepackage[english]{babel}
\usepackage{amsmath, amsthm, amssymb}
\usepackage[usenames,svgnames]{xcolor}
\usepackage{tikz-cd}
\usetikzlibrary{shapes,arrows,intersections}
\usetikzlibrary{matrix,fit,calc,trees,positioning,arrows,chains,shapes.geometric,shapes}
\begin{document}
\begin{tikzpicture}
\begin{scope}
\path[clip] (0,0) -- (0,3) -- (1,0.3);
\fill[blue!25!white, draw=blue!50!black] (0,3) circle (10mm);
\end{scope}
\draw(0.25,1.75) node[blue!50!black] {$\theta$};
\draw (0,3) node[above left]{$O$};
\draw[->] (0,0) -- (0,4) node[above]{$z$};
\draw[->] (0,3) -- (3,3) node[right]{$y$};
\draw[->] (0,3) -- (-1.5,1.8)node[below left]{$z$};
\draw (1,0.3) node{$\bullet$} node[right]{$M(m)$};
\draw[dashed] (0,3) -- (1,3.4);
\draw[dashed] (1,0.3) -- (1,3.4);
\draw (0.8,3.12) -- (0.8,3.32);
\draw (1,3.2) -- (0.8,3.12);
\draw[Aquamarine!50!black] (0,3) -- (1,0.3) node[midway, above right, Aquamarine!50!black]{$l$};
\draw[red, ->] (1,0.3) -- (1,-0.5) node[below]{$m\overrightarrow{g}$};
\draw[red, ->] (1,0.3) -- (0.75,0.975) node[left]{$\overrightarrow{T}$};
\begin{scope}
\path[clip] (-1.5,1.8) -- (0,3) -- (1,3.4);
\fill[Aquamarine!25!white, draw=Aquamarine!50!black] (0,3) circle (5mm);
\end{scope}
\end{tikzpicture}
\end{document}
我得到了这张图片,它接近我想要的,但我想在上面的水平平面图中标记角度,但正如你所见,它显示不正确。知道为什么吗?我必须声明显式层吗?我尝试过,但没有成功\pgfdeclarelayer
请注意,我非常愿意改变标记角度的方式,因为这是我发现的最佳方式,但仍然发现它不太容易使用。
编辑:添加所需的结果
答案1
您的问题是,您正在剪切到具有指定角的三角形,而圆应该延伸到该三角形之外。即使您没有指定第三条边,它也会自动推断(就像您要填充该区域一样)。您可以向剪辑路径添加另一个点来修复它。
\PassOptionsToPackage{dvipsnames}{xcolor}
\documentclass[tikz]{standalone}
\begin{document}%
\begin{tikzpicture}
\begin{scope}
\path[clip] (0,0) -- (0,3) -- (1,0.3);
\fill[blue!25!white, draw=blue!50!black] (0,3) circle (10mm);
\end{scope}
\draw(0.25,1.75) node[blue!50!black] {$\theta$};
\draw (0,3) node[above left]{$O$};
\draw[->] (0,0) -- (0,4);
\draw[->] (0,3) -- (3,3);
\draw[->] (0,3) -- (-1.5,1.8);
\draw (1,0.3) node{$\bullet$} node[right]{$M(m)$};
\draw[dashed] (0,3) -- (1,3.4);
\draw[dashed] (1,0.3) -- (1,3.4);
\draw (0.8,3.12) -- (0.8,3.32);
\draw (1,3.2) -- (0.8,3.12);
\draw[Aquamarine!50!black] (0,3) -- (1,0.3) node[midway, above right, Aquamarine!50!black]{$l$};
\draw[red, ->] (1,0.3) -- (1,-0.5) node[below]{$m\overrightarrow{g}$};
\draw[red, ->] (1,0.3) -- (0.75,0.975) node[left]{$\overrightarrow{T}$};
\begin{scope}
\path[clip] (-1.5,1.8) -- (0,3) -- (1,3.4) -- (1,1.8);
\fill[Aquamarine!25!white, draw=Aquamarine!50!black] (0,3) circle (5mm);
\end{scope}
\end{tikzpicture}
另一个选择是使用arc
操作而不是绘制完整的圆并进行裁剪,但这需要您知道角度。您也可以使用图片angle
,如 tikz 手册第 2.22 节所述。
稍微不相关的是,这看起来实际上也是一种 3D 表示。您可以在 中使用三维坐标,它会将它们投影到纸上(您可以通过设置选项、和 来tikz
更改投影,但默认值非常好。)这还会导致在 xy 平面上自动绘制圆圈,因此您可以通过设置范围在任何平面上绘制圆圈(或直角等)。请参阅x=
y=
z=
在三维平面上绘制圆圈。
例如,如果希望海蓝宝石角度位于 xz 平面,则可以使用
\fill[Aquamarine!25!white, draw=Aquamarine!50!black] (0,3) [y={(0,0,1)}] circle (.5);
答案2
所以我误解了原始描述中所需的角度(尽管我说剪切路径是错误的,这是对的),并且我艾玛的回答涵盖了 OP 所追求的所有内容。
我认为问题在于你裁剪的路径没有裁剪出正确的部分。使用路径,\path[clip] (1,3) -- (0,3) -- (1,3.4);
我得到了我认为你想要的角度。
\documentclass[a4paper]{article}
\PassOptionsToPackage{dvipsnames}{xcolor}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\begin{scope}
\path[clip] (0,0) -- (0,3) -- (1,0.3);
\fill[blue!25!white, draw=blue!50!black] (0,3) circle (10mm);
\end{scope}
\draw(0.25,1.75) node[blue!50!black] {$\theta$};
\draw (0,3) node[above left]{$O$};
\draw[->] (0,0) -- (0,4);
\draw[->] (0,3) -- (3,3);
\draw[->] (0,3) -- (-1.5,1.8);
\draw (1,0.3) node{$\bullet$} node[right]{$M(m)$};
\draw[dashed] (0,3) -- (1,3.4);
\draw[dashed] (1,0.3) -- (1,3.4);
\draw (0.8,3.12) -- (0.8,3.32);
\draw (1,3.2) -- (0.8,3.12);
\draw[Aquamarine!50!black] (0,3) -- (1,0.3) node[midway, above right, Aquamarine!50!black]{$l$};
\draw[red, ->] (1,0.3) -- (1,-0.5) node[below]{$m\overrightarrow{g}$};
\draw[red, ->] (1,0.3) -- (0.75,0.975) node[left]{$\overrightarrow{T}$};
\begin{scope}
\path[clip] (1,3) -- (0,3) -- (1,3.4);
\fill[Aquamarine!25!white, draw=Aquamarine!50!black] (0,3) circle (5mm);
\end{scope}
\end{tikzpicture}
\end{document}
因此,为了让这个答案更有用,我想我应该添加一个如何编写它的方法,定义一些坐标,然后根据这些坐标编写大部分草图。
\documentclass{article}
\PassOptionsToPackage{dvipsnames}{xcolor}
\usepackage{tikz}
\usetikzlibrary{calc,intersections}
\begin{document}
\begin{tikzpicture}[scale=2]
\coordinate [label=below left:{$x$}] (xaxe) at (-1.5,1.8);
\coordinate [label=right:{$y$}] (yaxe) at (3,3);
\coordinate [label=above:{$z$}] (zaxe) at (0,4);
\coordinate (zmin) at (0,0);
\coordinate [label=above left:{$O$}] (origin) at (0,3);
\draw [->] (origin) -- (xaxe);
\draw [->] (origin) -- (yaxe);
\draw [->] (zmin) -- (zaxe);
\coordinate (m) at (1,0.3);
\begin{scope}
\path[name path global=thetaclip,clip] (zmin) -- (origin) -- (m) -- cycle;
\path[fill=blue!25!white, draw=blue!50!black, name path global=thetacirc] (origin) circle (10mm);
\end{scope}
\path [name intersections={of=thetacirc and thetaclip}] let
\p1 = ($($(intersection-1)!0.5!(intersection-2)$)-(origin)$),
\n1 = {veclen(\x1,\y1)},
\p2 = (35*\x1 / \n1, 35*\y1 / \n1)
in
(origin) -- ++(\p2) node {$\theta$};
\draw[dashed] (m) -- ($($(origin)!(m)!(yaxe)$)+(0,0.4)$) coordinate (abovem);
\draw[dashed] (origin) -- (abovem);
\draw (abovem) +(-0.2,-0.08) -- ++(-0.2,-0.28) -- ++(0.2,0.08);
\draw[Aquamarine!50!black] (origin) -- (m) node[midway, above right, Aquamarine!50!black]{$l$};
\draw[red, ->] (m) -- ++(0,-0.8) node[below]{$m\overrightarrow{g}$};
\draw[red, ->] (m) -- ($(m)!8mm!(origin)$) node[left]{$\overrightarrow{T}$};
\begin{scope}
\path[name path global=phiclip,clip] (xaxe) -- (origin) -- (abovem) -- (m) -- cycle;
\path[fill=Aquamarine!25!white, draw=Aquamarine!50!black,name path global=phicirc] (origin) circle (5mm);
\end{scope}
\path [name intersections={of=phicirc and phiclip}] let
\p1 = ($($(intersection-1)!0.5!(intersection-2)$)-(origin)$),
\n1 = {veclen(\x1,\y1)},
\p2 = (20*\x1 / \n1, 20*\y1 / \n1)
in
(origin) -- ++(\p2) node {$\phi$};
\node [label=right:{$M(m)$}] at (m) {$\bullet$};
\end{tikzpicture}
\end{document}