如何绘制“极坐标”图

如何绘制“极坐标”图

我的目标是绘制一个笛卡尔平面,其中有一个以原点为中心的圆,一个与圆内切的原点相切的直角三角形,该三角形有一个名为 theta 的角和名为 x 和 y 的边,轴不应命名。可能在每个象限中。我想制作这样的图,以便“解释”极坐标并展示如何获得公式。

我了解很多数学 LaTeX,但对绘制此类图表一无所知,非常感谢您的帮助。

编辑: 好吧,非常抱歉,我的文字似乎有点不清楚。我添加了一张图片。 在此处输入图片描述

我也想为三维球面坐标画一幅类似的图。我发现并做了一些修改。如下所示

\tdplotsetmaincoords{60}{110}
\pgfmathsetmacro{\rvec}{.8}
\pgfmathsetmacro{\thetavec}{30}
\pgfmathsetmacro{\phivec}{60}
\begin{center}
\begin{tikzpicture}[scale=5,tdplot_main_coords]

\coordinate (O) at (0,0,0);
\tdplotsetcoord{P}{\rvec}{\thetavec}{\phivec}
\draw[thick,->] (0,0,0) -- (1,0,0) node[anchor=north east]{$x$};
\draw[thick,->] (0,0,0) -- (0,1,0) node[anchor=north west]{$y$};
\draw[thick,->] (0,0,0) -- (0,0,1) node[anchor=south]{$z$};
\draw[-stealth,color=red] (O) -- (P);
\draw[dashed, color=red] (O) -- (Pxy);
\draw[dashed, color=red] (P) -- (Pxy);
\tdplotdrawarc{(O)}{0.2}{0}{\phivec}{anchor=north}{$\phi$}
\tdplotsetthetaplanecoords{\phivec}
\tdplotdrawarc[tdplot_rotated_coords]{(0,0,0)}{0.5}{0}{\thetavec}{anchor=south west}{$\theta$}
\draw[dashed,tdplot_rotated_coords] (\rvec,0,0) arc (0:90:\rvec);
\draw[dashed] (\rvec,0,0) arc (0:90:\rvec);
\tdplotsetrotatedcoords{\phivec}{\thetavec}{0}

\end{tikzpicture}
\end{center}

但是现在,我仍然希望有从点 P 的投影到 xy 轴 Pxy 到 x 和 y 轴的虚线。

答案1

像往常一样,这是新手的第一个问题。Asymptote 有margin选项,所以箭头刚好接触到目标。TikZ 有漂亮的内置stealth箭头。

在此处输入图片描述

// http://asymptote.ualberta.ca/
unitsize(2cm);
real a=40;
pair M=dir(a);
draw((M.x,0)--M,red+dashed); label("$x$",(M.x,0),S);
draw((0,M.y)--M,red+dashed); label("$y$",(0,M.y),W);
draw(arc((0,0),.2,0,a),Arrow(TeXHead), TrueMargin(0.5 linewidth(currentpen))); 
label(scale(.8)*"$\theta$",.3dir(a/2));
draw(Label(scale(.8)*"$r$",align=.5NW),(0,0)--M,red);
draw(unitcircle,blue);
draw((-1.25,0)--(1.25,0),Arrow(TeXHead));
draw((0,-1.25)--(0,1.25),Arrow(TeXHead));
label("$O$",(0,0),SW);
shipout(bbox(2mm,invisible));

在此处输入图片描述

\documentclass{article}
\usepackage{tikz,lipsum}
\begin{document}
\lipsum[1]
\begin{center}
\begin{tikzpicture}[scale=2]
\def\a{40}
\path 
(0,0) coordinate (O)
(\a:1) coordinate (M);
\draw[dashed,magenta] 
(O-|M) node[black,below]{$x$} --(M)
(O|-M) node[black,left]{$y$} --(M);
\draw[-stealth] (0:.25) arc(0:\a:.25);
\path (\a/2:.35) node[scale=.8]{$\theta$};
\draw[magenta] (O)--(M) node[midway,above]{$r$};
\draw[->] (-1.25,0)--(1.25,0);
\draw[->] (0,-1.25)--(0,1.25);
\draw[teal] (O) circle(1) node[black,below left]{$O$};
\end{tikzpicture}    
\end{center}
\lipsum[2]
\end{document}

相关内容