我从 tikz.net 获得了这个 MWE,但我想编辑角度:
- 在 x 轴和 z 轴之间添加新角度 (\varphi)
- 将当前 y 轴和 z 轴之间的角度 (\theta) 更改为 y 轴和向量 r 之间的角度,而不是 z 轴和向量 r 之间的角度
这就是我想要实现的目标:
这是 Latex 代码:
\documentclass[border=3pt]{standalone}
%Drawing
\usepackage{tikz}
%3D
\usepackage{tikz-3dplot}
%Tikz Library
\usetikzlibrary{angles, quotes, intersections}
%Styles
\tikzset{axis/.style={thick,-latex}}
\tikzset{vec/.style={thick,blue}}
\tikzset{univec/.style={thick,red,-latex}}
%Notation
\usepackage{physics}
\usepackage{bm}
\begin{document}
\tdplotsetmaincoords{70}{110}
%
\pgfmathsetmacro{\thetavec}{48.17}
\pgfmathsetmacro{\phivec}{63.5}
%
\begin{tikzpicture}[tdplot_main_coords]
%Axis
\draw[axis] (0,0,0) -- (6.5,0,0) node [pos=1.1] {$x$};
\draw[axis] (0,0,0) -- (0,6,0) node [pos=1.05] {$y$};
\draw[axis] (0,0,0) -- (0,0,5.5) node [pos=1.05] {$z$};
%Vectors
\tdplotsetcoord{P}{6}{\thetavec}{\phivec}
\draw[vec] (0,0,0) -- (P) node [midway, above] {$r$};
\draw[thick] (0,0,0) -- (2,4,0);
\draw[dashed] (0,0,0) -- (2,0,4);
\draw[dashed] (2,0,4) -- (2,0,0);
\draw[dashed] (2,0,4) -- (P);
%Help Lines
\draw[dashed] (2,4,4) -- (2,4,0);
\draw[dashed] (2,0,0) -- (2,4,0) node [pos=-0.1] {$$};
\draw[dashed] (0,4,0) -- (2,4,0) node [pos=-0.3] {$$};
\draw[dashed] (0,0,4) -- (2,4,4) node [pos=-0.1] {$$};
%Point
\node[fill=black, circle, inner sep=0.8pt] at (2,4,4) {};
%Angles
\tdplotdrawarc{(0,0,0)}{0.7}{0}{\phivec}{below}{$\phi$}
\tdplotsetthetaplanecoords{\phivec}
\tdplotdrawarc[tdplot_rotated_coords]{(0,0,0)}{0.5}{0}{\thetavec}{}{}
\node at (0,0.25,0.67) {$\theta$};
\end{tikzpicture}
\end{document}
答案1
极坐标 - 圆柱坐标 - 球坐标
这是我很久以前画的图。希望对你有帮助!
我只使用普通的 TikZ(参见下页)。
\documentclass[tikz,border=5mm]{standalone}
\usepackage[utf8]{vietnam}
\usepackage{amssymb,amsmath,amsthm}
\usetikzlibrary{calc,angles,quotes}
\pagecolor{yellow!15}
\begin{document}
\def\r{{\color{cyan}r}}
\def\cphi{{\color{blue}\varphi}}
\def\ctheta{{\color{red}\theta}}
\begin{tikzpicture}
\path
(0,0) coordinate (O) node[below left]{O}
(3.5,0) coordinate (X) node[below]{$x$}
(0,2) coordinate (Y) node[left]{$y$}
($(X)+(Y)$) coordinate (M) node[above right]{$M$};
\pic[blue,-stealth,draw,"$\varphi$",angle radius=8mm, angle eccentricity=1.3]{angle=X--O--M};
\draw[dashed] (X)--(M) (Y)--(M);
\draw[cyan,thick] (O)--(M) node[midway,above]{$r$};
\begin{scope}[shorten >=-5mm,shorten <=-10mm,->]
\draw (O)--(X);
\draw (O)--(Y);
\end{scope}
\foreach \p in {X,Y,O,M}
\draw[fill=white] (\p) circle(1pt);
\path (current bounding box.west) +(-2,1) node[align=left,font=\sffamily,fill=gray!20,inner sep=2mm,rounded corners]{
Polar Coordinates\\
Hệ tọa độ cực $(\r,\cphi)$\\[2mm]
$x=\r \cos\cphi$\\
$y=\r \sin\cphi$\\[2mm]
$0\leq \r$\\
$0\leq\cphi< 2\pi$
};
\end{tikzpicture}
\begin{tikzpicture}
\path
(0,0) coordinate (O) +(150:.25) node{O}
(-135:1.5) coordinate (X) node[left]{$x$}
(0:3.5) coordinate (Y) node[above]{$y$}
(90:3.5) coordinate (Z) node[left]{$z$}
($(X)+(Y)$) coordinate (Mxy)
($(Mxy)+(Z)$) coordinate (M) node[above right]{$M$};
\pic[blue,-stealth,draw,"$\varphi$",angle radius=5mm]{angle=X--O--Mxy};
\draw[dashed] (O)--(M)
(X)--(Mxy) (Y)--(Mxy) (Mxy)--(M) (Z)--(M);
\draw[cyan,thick] (O)--(Mxy) node[pos=.6,above]{$r$};
\begin{scope}[shorten >=-5mm,->]
\draw (O)--(X);
\draw (O)--(Y);
\draw (O)--(Z);
\end{scope}
\foreach \p in {X,Y,Z,O,M,Mxy}
\draw[fill=white] (\p) circle(1pt);
\path (current bounding box.west) +(-1.5,1) node[align=left,font=\sffamily,fill=gray!20,inner sep=2mm,rounded corners]{
Cylindrical Coordinates\\
Hệ tọa độ trụ $(\r,\cphi,z)$\\[2mm]
$x=\r \cos\cphi$\\
$y=\r \sin\cphi$\\
$z=z$\\[2mm]
$0\leq \r$\\
$0\leq\cphi< 2\pi$\\
$z\in\mathbb{R}$
};
\end{tikzpicture}
\begin{tikzpicture}
\path
(0,0) coordinate (O) +(150:.25) node{O}
(-135:1.5) coordinate (X) node[left]{$x$}
(0:3.5) coordinate (Y) node[above]{$y$}
(90:3.5) coordinate (Z) node[left]{$z$}
($(X)+(Y)$) coordinate (Mxy)
($(Mxy)+(Z)$) coordinate (M) node[above right]{$M$};
\pic[blue,-stealth,draw,"$\varphi$",angle radius=5mm]{angle=X--O--Mxy};
\pic[red,stealth-,draw,"$\theta$",angle radius=8mm]{angle=M--O--Z};
\draw[dashed] (O)--(Mxy)
(X)--(Mxy) (Y)--(Mxy) (Mxy)--(M) (Z)--(M);
\draw[cyan,thick] (O)--(M) node[midway,above]{$r$};
\begin{scope}[shorten >=-5mm,->]
\draw (O)--(X);
\draw (O)--(Y);
\draw (O)--(Z);
\end{scope}
\foreach \p in {X,Y,Z,O,M,Mxy}
\draw[fill=white] (\p) circle(1pt);
\path (current bounding box.west) +(-1.5,1) node[align=left,font=\sffamily,fill=gray!20,inner sep=2mm,rounded corners]{
Spherical Coordinates\\
Hệ tọa độ cầu $(\r,\cphi,\ctheta)$\\[2mm]
$x=\r \cos\cphi\;\sin\ctheta$\\
$y=\r \sin\cphi\;\sin\ctheta$\\
$z=\r \cos\ctheta$\\[2mm]
$0\leq \r$\\
$0\leq\cphi< 2\pi$\\
$0\leq\ctheta\leq\pi$
};
\end{tikzpicture}
\end{document}