在圆柱坐标和球坐标中绘制

在圆柱坐标和球坐标中绘制

我可以尝试在 TikZ 中绘制这个:

first image second image

我设法绘制了坐标轴。第一张图是圆柱坐标系,第二张是球坐标系。我不知道如何在球坐标系中绘制箭头标签、曲线和许多其他东西。

我已经开始阅读 Till Tantau 的手册,但现在我是 TikZ 的新手,我不明白该手册中的很多内容。

答案1

我不太了解 3D 行为tikz,但这里有一种方法可以在 Asymptote 中使用一堆线条、圆弧和标签来制作一张图片。

我使用的一些内置 Asymptote 命令:

  • X是单位向量 (1,0,0),类似地,YZ
  • expi(theta,phi) 返回 theta,phi 方向的单位向量

更新采纳 Charles Staats 的一些建议

  • 将虚线改为实线
  • 减少标记线和弧的重量并增加轴的重量
  • 添加了一个轻质、几乎透明的球形表面,体积元素就位于其上……我认为这有助于透视

 

\documentclass{article}
\usepackage{asymptote}

\begin{document}

\begin{asy}[width=0.5\textwidth]
settings.render=6;
settings.prc=false;
import three;
import graph3;
import grid3;
currentprojection=orthographic(1,-0.175,0.33,up=Z);

//Draw Axes
pen thickblack = black+0.75;
real axislength = 1.33;
draw(L=Label("$x$", position=Relative(1.1), align=SW), O--axislength*X,thickblack, Arrow3); 
draw(L=Label("$y$", position=Relative(1.1), align=N), O--axislength*Y,thickblack, Arrow3); 
draw(L=Label("$z$", position=Relative(1.1), align=N), O--axislength*Z,thickblack, Arrow3); 

//Set parameters of start corner of polar volume element
real r = 1;
real q=0.3pi; //theta
real f=0.35pi; //phi

real dq=0.15; //dtheta
real df=0.3; //dphi
real dr=0.1; 


// Arq is A + dr*rhat + dq*qhat, etc
triple A = r*expi(q,f);
triple Ar = (r+dr)*expi(q,f);
triple Aq = r*expi(q+dq,f);
triple Arq = (r+dr)*expi(q+dq,f);
triple Af = r*expi(q,f+df);
triple Arf = (r+dr)*expi(q,f+df);
triple Aqf = r*expi(q+dq,f+df);
triple Arqf = (r+dr)*expi(q+dq,f+df);

pen thingray = gray+0.33;

draw(A--Ar);
draw(Aq--Arq);
draw(Af--Arf);
draw(Aqf--Arqf);
draw( arc(O,A,Aq) ,thickblack );
draw( arc(O,Af,Aqf),thickblack );
draw( arc(O,Ar,Arq) );
draw( arc(O,Arf,Arqf) );
draw( arc(O,Ar,Arq) );
draw( arc(O,A,Af),thickblack );
draw( arc(O,Aq,Aqf),thickblack );
draw( arc(O,Ar,Arf) );
draw( arc(O,Arq,Arqf) );

pen thinblack = black+0.25;

//phi arcs
draw(O--expi(pi/2,f),thinblack);
draw("$\varphi$", arc(O,0.5*X,0.5*expi(pi/2,f)),thinblack,Arrow3);
draw(O--expi(pi/2,f+df),thinblack);
draw( "$d\varphi$", arc(O,expi(pi/2,f),expi(pi/2,f+df) ),thinblack );
draw( A.z*Z -- A,thinblack);
draw(L=Label("$r\sin{\theta}$",position=Relative(0.5),align=N), A.z*Z -- Af,thinblack);

//cotheta arcs
draw( arc(O,Aq,expi(pi/2,f)),thinblack );
draw( arc(O,Aqf,expi(pi/2,f+df) ),thinblack);

//theta arcs
draw(O--A,thinblack);
draw(O--Aq,thinblack);
draw("$\theta$", arc(O,0.25*length(A)*Z,0.25*A),thinblack,Arrow3);
draw(L=Label("$d\theta$",position=Relative(0.5),align=NE) ,arc(O,0.66*A,0.66*Aq),thinblack );


// inner surface
triple rin(pair t) {  return r*expi(t.x,t.y);}
surface inner=surface(rin,(q,f),(q+dq,f+df),16,16);
draw(inner,emissive(gray+opacity(0.33)));
//part of a nearly transparent sphere to help see perspective
surface sphere=surface(rin,(0,0),(pi/2,pi/2),16,16);
draw(sphere,emissive(gray+opacity(0.125)));


// dr and rdtheta labels
draw(L=Label("$dr$",position=Relative(1.1)), Af + 0.5*(Arf-Af)--Af + 0.5*(Arf-Af)+0.25*Z,dotted);
triple U=expi(q+0.5*dq,f);
draw(L=Label("$rd\theta$",position=Relative(1.1)), r*U ---r*(1.33*U.x,1.33*U.y,U.z),dotted );

\end{asy}

\end{document}

enter image description here

更新 #2

Charles Staats 指出了斜投影的良好参数,它与原始图片更匹配。使用currentprojection=obliqueXwidth=\textwidth并稍微编辑标签以更好地适应此投影:

enter image description here

正字法代码:

\documentclass{article}
\usepackage{asymptote}

\begin{document}

\begin{asy}[width=\textwidth]
settings.render=6;
settings.prc=false;
import three;
import graph3;
import grid3;
currentprojection=obliqueX;

//Draw Axes
pen thickblack = black+0.75;
real axislength = 1.0;
draw(L=Label("$x$", position=Relative(1.1), align=SW), O--axislength*X,thickblack, Arrow3); 
draw(L=Label("$y$", position=Relative(1.1), align=E), O--axislength*Y,thickblack, Arrow3); 
draw(L=Label("$z$", position=Relative(1.1), align=N), O--axislength*Z,thickblack, Arrow3); 

//Set parameters of start corner of polar volume element
real r = 1;
real q=0.25pi; //theta
real f=0.3pi; //phi

real dq=0.15; //dtheta
real df=0.15; //dphi
real dr=0.15; 

triple A = r*expi(q,f);
triple Ar = (r+dr)*expi(q,f);
triple Aq = r*expi(q+dq,f);
triple Arq = (r+dr)*expi(q+dq,f);
triple Af = r*expi(q,f+df);
triple Arf = (r+dr)*expi(q,f+df);
triple Aqf = r*expi(q+dq,f+df);
triple Arqf = (r+dr)*expi(q+dq,f+df);

pen thingray = gray+0.33;

draw(A--Ar);
draw(Aq--Arq);
draw(Af--Arf);
draw(Aqf--Arqf);
draw( arc(O,A,Aq) ,thickblack );
draw( arc(O,Af,Aqf),thickblack );
draw( arc(O,Ar,Arq) );
draw( arc(O,Arf,Arqf) );
draw( arc(O,Ar,Arq) );
draw( arc(O,A,Af),thickblack );
draw( arc(O,Aq,Aqf),thickblack );
draw( arc(O,Ar,Arf) );
draw( arc(O,Arq,Arqf) );

pen thinblack = black+0.25;

//phi arcs
draw(O--expi(pi/2,f),thinblack);
draw("$\varphi$", arc(O,0.5*X,0.5*expi(pi/2,f)),thinblack,Arrow3);
draw(O--expi(pi/2,f+df),thinblack);
draw( "$d\varphi$", arc(O,expi(pi/2,f),expi(pi/2,f+df) ),thinblack );
draw( A.z*Z -- A,thinblack);
draw(L=Label("$r\sin{\theta}$",position=Relative(0.5),align=N), A.z*Z -- Af,thinblack);

//cotheta arcs
draw( arc(O,Aq,expi(pi/2,f)),thinblack );
draw( arc(O,Aqf,expi(pi/2,f+df) ),thinblack);

//theta arcs
draw(O--A,thinblack);
draw(O--Aq,thinblack);
draw("$\theta$", arc(O,0.25*length(A)*Z,0.25*A),thinblack,Arrow3);
draw(L=Label("$d\theta$",position=Relative(0.5),align=NE) ,arc(O,0.66*A,0.66*Aq),thinblack );


// inner surface
triple rin(pair t) {  return r*expi(t.x,t.y);}
surface inner=surface(rin,(q,f),(q+dq,f+df),16,16);
draw(inner,emissive(gray+opacity(0.33)));
//part of a nearly transparent sphere to help see perspective
surface sphere=surface(rin,(0,0),(pi/2,pi/2),16,16);
draw(sphere,emissive(gray+opacity(0.125)));


// dr and rdtheta labels
triple V= Af + 0.5*(Arf-Af);
draw(L=Label("$dr$",position=Relative(1.1)), V--(1.5*V.x,1.5*V.y,V.z),dotted);
triple U=expi(q+0.5*dq,f);
draw(L=Label("$rd\theta$",position=Relative(1.1)), r*U ---r*(1.66*U.x,1.66*U.y,U.z),dotted );

\end{asy}

\end{document}

答案2

我为我的学生准备了一份电磁场理论的讲义。我画出了圆柱坐标系中使用的表面。为此,我使用了tikz-3dplot包。这是代码和输出。我希望这对您来说是一个起点。

\documentclass{article}
\usepackage{tikz,tikz-3dplot}
\begin{document}

\begin{figure}
\centering
\tdplotsetmaincoords{70}{120}
\begin{tikzpicture}[tdplot_main_coords][scale=0.75]
\tikzstyle{every node}=[font=\small]
\draw[thick,-latex] (0,0,0) -- (6,0,0) node[anchor=north east]{$x$};
\draw[thick,-latex] (0,0,0) -- (0,6,0) node[anchor=north west]{$y$};
\draw[thick,-latex] (0,0,0) -- (0,0,6) node[anchor=south]{$z$};
\draw [thick](0,0,0) circle (3);
\draw [thick](0,0,4) circle (3);
\draw [thick](1.9,-2.35,0) -- (1.9,-2.35,4) node[midway, left]{$r=r_1$ surface};
\draw [thick](-1.9,2.35,0) -- (-1.9,2.35,4);
\filldraw[fill=orange, nearly transparent] (-4,-4,4) -- (4,-4,4) --  (4,5,4) -- (-4,5,4) -- (-4,-4,4);
\filldraw[fill=blue, nearly transparent] (0,0,4) -- (5.2,6,4) --  (5.2,6,0) -- (0,0,0) -- (0,0,4);
\filldraw [color=blue](2,2.25,4) circle (0.075cm) ;
\draw (-4,5,4) node[anchor=south]{$z=z_1$ plane};
\draw (5.2,6,0) node[anchor=south west]{$\phi=\phi_1$ plane};
\node at (1.8,1,4)  { $P_1(r_1,\phi_1,z_1)$};
\draw[ultra thick,-latex](2,2.25,4) -- (3,3.45,4) node[anchor=north] {$\mathbf{a}_r$};
\draw[ultra thick,-latex](2,2.25,4) -- (1,2.5,4) node[anchor=north west] {$\mathbf{a}_\phi$};
\draw[ultra thick,-latex](2,2.25,4) -- (2,2.25,4.75) node[anchor=north west] {$\mathbf{a}_z$};
\draw [thick,->](4,0,0) arc (0:45:4 and 4.5);
\draw (3.6,2,0) node[anchor=north] {$\phi_1$};
\draw[ultra thick,-latex](0,0,0) -- (2,2.35,0);
\draw (1,1,0) node[anchor=north] {$r_1$};
\draw [ultra thick] (2,2.25,4)--(1.95,2.25,0);

\draw[ultra thick](0.1,0,4) -- (-0.1,0,4) node[anchor=south west] {$z_1$};
\end{tikzpicture}
\end{figure}
\end{document}

enter image description here

答案3

首先,我要把所有的功劳归功于@mrc。他的作品相当出色。

我想完善他作品的一些细节。基本上,他缺少两个部分,这有时会使可视化变得困难。例如,由于缺少两个部分,立方体的底部可能看起来像面向读者的一侧。小细节是角度增量的箭头、倾斜的文本、较小的字体和不同的视角,但我再次在@mrc 作品的基础上进行构建。Spherical Coordinates

 \begin{asy}[]
  if(!settings.multipleView) settings.batchView=false;
  import three;
  settings.tex="pdflatex";
  defaultfilename="input-1";
  if(settings.render < 0) settings.render=40;
  settings.outformat="";
  settings.inlineimage=true;
  settings.embed=true;
  settings.toolbar=false;
  defaultpen(fontsize(8pt));



  size(9.5cm);
  settings.outformat="pdf";
  settings.prc=false;
  import graph3;
  import grid3;

  currentprojection=orthographic(
  camera=(2.9637389483254,1.48144594554777,1.03154384251566),
  up=(-0.00245695858860577,0.00028972293310393,0.00664306468788549),
  target=(0,0,0),
  zoom=0.971150237157127);


  //Draw Axes
  pen thickblack = black+0.75;
  real axislength = 1.0;
  draw(L=Label("$x$", position=Relative(1.1), align=SW),
  O--axislength*X,thickblack, Arrow3);
  draw(L=Label("$y$", position=Relative(1.1), align=E),
  O--axislength*Y,thickblack, Arrow3);
  draw(L=Label("$z$", position=Relative(1.1), align=N),
  O--axislength*Z,thickblack, Arrow3);

  //Set parameters of start corner of polar volume element
  real r = 0.8;
  real q=0.25pi; //theta
  real f=0.3pi; //phi

  real dq=0.25; //dtheta
  real df=0.25; //dphi
  real dr=0.15;

  triple A = r*expi(q,f);
  triple Ar = (r+dr)*expi(q,f);
  triple Aq = r*expi(q+dq,f);
  triple Arq = (r+dr)*expi(q+dq,f);
  triple Af = r*expi(q,f+df);
  triple Arf = (r+dr)*expi(q,f+df);
  triple Aqf = r*expi(q+dq,f+df);
  triple Arqf = (r+dr)*expi(q+dq,f+df);

  //label("$A$",A);
  //label("$Ar$",Ar);
  //label("$Aq$",Aq);
  //label("$Arq$",Arq);
  //label("$Af$",Af);
  //label("$Aqf$",Aqf);
  //label("$Arf$",Arf);
  //label("$\; \; \quad Arqf$",Arqf);


  pen thingray = gray+0.33;

  draw(A--Ar);
  draw(Aq--Arq);
  draw(Af--Arf);
  draw(Aqf--Arqf);
  draw(O--Af, dashed);
  draw(O--Aqf);
  draw( arc(O,A,Aq) ,thickblack );
  draw( arc(O,Af,Aqf),thickblack );
  draw( arc(O,Ar,Arq) );
  draw( arc(O,Arf,Arqf) );
  draw( arc(O,Ar,Arq) );
  draw( arc(O,A,Af),thickblack );
  draw( arc(O,Aq,Aqf),thickblack );
  draw( arc(O,Ar,Arf) );
  draw( arc(O,Arq,Arqf));

  pen thinblack = black+0.25;

  //phi arcs
  draw(O--expi(pi/2,f),thinblack);
  draw("$\phi$", arc(O,0.5*X,0.5*expi(pi/2,f)),thinblack,Arrow3);
  draw(O--expi(pi/2,f+df),thinblack);
  draw( "$d\phi$", arc(O,expi(pi/2,f),expi(pi/2,f+df) ),thinblack , Arrow3);
  draw( A.z*Z -- A,thinblack);
  draw(L=Label(rotate(-5)*"$r\sin{\theta}$",position=Relative(0.5),align=N), A.z*Z -- Af,thinblack);

  //cotheta arcs
  draw( arc(O,Aq,expi(pi/2,f)),thinblack );
  draw( arc(O,Aqf,expi(pi/2,f+df) ),thinblack);

  //theta arcs
  draw(O--A,thinblack);
  draw(O--Aq,thinblack);
  draw(L=Label("$\theta$",position=Relative(0.5), align=NE),
  arc(O,0.25*length(A)*Z,0.25*A),thinblack,Arrow3);
  draw(L=Label("$d\theta$",position=Relative(0.5),align=NE) ,arc(O,0.66*A,0.66*Aq),
  thinblack, Arrow3 );


  // inner surface
  triple rin(pair t) { return r*expi(t.x,t.y);}
  triple rout(pair t) { return 1.24*r*expi(t.x,t.y);}
  surface inner=surface(rin,(q,f),(q+dq,f+df),16,16);
  draw(inner,emissive(gray+opacity(0.33)));

  // surface sider=surface(rin,(f,r),(f+df,r+dr),16,16);
  // draw(sider,emissive(gray+opacity(0.33)));


  //part of a nearly transparent sphere to help see perspective
  surface sphere=surface(rout,(0,0),(pi/2,pi/2),26,26);
  draw(sphere,emissive(gray+opacity(0.125)));


  // dr and rdtheta labels
  triple V= Af + 0.5*(Arf-Af);
  draw(L=Label("$dr$",position=Relative(1.1)), V--(1.5*V.x,1.5*V.y,V.z),dotted);
  triple U=expi(q+0.5*dq,f);
  draw(L=Label("$rd\theta$",position=Relative(1.1)),
  r*U ---r*(1.66*U.x,1.66*U.y,U.z),dotted );
\end{asy}

答案4

我决定从一个非常不同的角度来绘制这个图。我不会在这里包含问题,而是指向我包含代码和图的链接。 三维球面体积元素

相关内容