PGF:在三维轴环境中绘制纵向圆弧

PGF:在三维轴环境中绘制纵向圆弧

我想在这里绘制一个类似于第一个球体:http://www.texample.net/tikz/examples/map-projections/

但当然,情况有所不同。这是我目前所做的: 我的领域

虚线位于箭头后面,实线位于上方,以产生箭头位于球体中的错觉。

我的做法有点棘手,可能不是最优雅的方法。我在背景中创建了一个倾斜的球体(表面图),并用一个更好看的“球”覆盖它。我最初打算将表面图球体作为实际球体,然后决定它看起来不够好。但我把它保留在背景中,因为我需要轴环境,因为没有轴 cs 我就无法做到这一点。

纬线基本上是从 (axis cs: 1,0,0) 点 (arc (0:360:1)) 开始的 360° 弧。事实证明,arc 将角度解释为极角(xy 平面中的角度),这使得操作变得简单。

但这似乎使经线无法实现。除了极角之外,有没有类似 arc3D 的东西可以知道方位角?或者我可以重新绘制纬线并将其旋转 90 度吗?有人知道其他解决方案吗?

我尝试不使用轴环境也失败了。实际上,我对我的轴解决方案并不不满,因为它使绘制箭头的方向更加容易(最终会如何)。

我希望我能清楚地解释我的问题是什么,并希望有人能提出一个简单的 arc3D 解决方案。;)

我的代码是:

\documentclass[tikz]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.9}
\usetikzlibrary{arrows.meta}
\tikzset{>=Latex}

\begin{document}
\begin{tikzpicture}
\def\tilt{45}
\def\azimuth{30}
\begin{axis}[%
axis equal,
width=14cm,
height=14cm,
hide axis,
enlargelimits=0.3,
view/h=\tilt,
view/v=\azimuth,
scale uniformly strategy=units only,
colormap={bluewhite}{color=(blue) color=(white)},   
]
\coordinate (X) at (axis cs: 1,0,0);
\coordinate (-X) at (axis cs: -1,0,0);
\coordinate (Y) at (axis cs: 0,1,0);
\coordinate (-Y) at (axis cs: 0,-1,0);
\coordinate (Z) at (axis cs: 0,0,1);
\coordinate (-Z) at (axis cs: 0,0,-1);
Kugel
        \addplot3[
        surf,
        shader= interp,
        opacity = 1,
        samples=2,
        domain=-1:1,y domain=0:2*pi,
        z buffer=sort
        ]
        ({sqrt(1-x^2) * cos(deg(y))},
        {sqrt( 1-x^2 ) * sin(deg(y))},
        x);
\filldraw[ball color=white] (axis cs: 0,0,0) circle (2.5cm);
%dashed lines
    %Breitengrade
    \pgfplotsinvokeforeach {-80,-60,...,80}{
        \pgfplotsextra{ 
            \pgfmathsetmacro\sinVis{sin(#1)/cos(#1)*sin(\azimuth)/cos(\azimuth)}
            % angle of "visibility"
            \pgfmathsetmacro\angVis{asin(min(1,max(\sinVis,-1)))}
            \coordinate (X) at (axis cs: {cos(#1)},0,{sin(#1)});
            \draw [gray,dashed] (X) arc (0:360:{100*cos(#1)});
        } }
%Achsen
\draw [-{>[scale=2]},gray] (axis cs: -1,0,0) -- (axis cs: 1.5,0,0) node [above] {$\sigma_x$};   %x-Achse
\draw [-{>[scale=2]},gray] (axis cs: 0,-1,0) -- (axis cs: 0,1.5,0) node [above] {$\sigma_y$};   %y-Achse
\draw [-{>[scale=2]},gray] (axis cs: 0,0,-1) node [below]{$\sigma_-$} -- (axis cs: 0,0,1.3) node [above] {$\sigma_+$};   %z-Achse

    \draw [-{>[scale=1]},cyan,line width = 3pt] (axis cs: 0,0,0) -- (axis cs: 0,0,1.1);
    \draw [-{>[scale=1]},blue,line width = 3pt] (axis cs: 0,0,0) -- (axis cs: 1,0,0);
%Arcs   
    \pgfplotsinvokeforeach {-80,-60,...,80}{
    \pgfplotsextra{ 
        \pgfmathsetmacro\sinVis{sin(#1)/cos(#1)*sin(\azimuth)/cos(\azimuth)}
         % angle of "visibility"
        \pgfmathsetmacro\angVis{asin(min(1,max(\sinVis,-1)))}
        \coordinate (X) at (axis cs: {cos(#1)},0,{sin(#1)});
        \draw [gray] (X) arc (0:\tilt+\angVis:{100*cos(#1)}) (X) arc (0:-180+\tilt-\angVis:{100*cos(#1)});
    } }
\end{axis}  
\end{tikzpicture}   
\end{document}

答案1

这样怎么样(我删除了你的一些功能):它基本上是在球面坐标。那么问题只是找出从可见到不可见的过渡发生在哪里。我使用的公式是我通过猜测确定的,它并不完美,可能需要改进。

代码

\documentclass[tikz, border=2mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.9}
\usetikzlibrary{arrows.meta}
\tikzset{>=Latex}

\begin{document}
\begin{tikzpicture}
\def\tilt{45}
\def\azimuth{30}
\begin{axis}[%
axis equal,
width=14cm,
height=14cm,
hide axis,
enlargelimits=0.3,
view/h=\tilt,
view/v=\azimuth,
scale uniformly strategy=units only,
colormap={bluewhite}{color=(blue) color=(white)},   
]
\coordinate (X) at (axis cs: 1,0,0);
\coordinate (-X) at (axis cs: -1,0,0);
\coordinate (Y) at (axis cs: 0,1,0);
\coordinate (-Y) at (axis cs: 0,-1,0);
\coordinate (Z) at (axis cs: 0,0,1);
\coordinate (-Z) at (axis cs: 0,0,-1);
\filldraw[ball color=white] (axis cs: 0,0,0) circle (2.47cm);
    \pgfplotsinvokeforeach {-80,-60,...,80}{
        \pgfplotsextra{ 
            \pgfmathsetmacro\sinVis{sin(#1)/cos(#1)*sin(\azimuth)/cos(\azimuth)}
            % angle of "visibility"
            \pgfmathsetmacro\angVis{asin(min(1,max(\sinVis,-1)))}
            \coordinate (X) at (axis cs: {cos(#1)},0,{sin(#1)});
            \draw [densely dashed] (X) arc (0:360:{100*cos(#1)});
        } }
    \pgfplotsinvokeforeach {-80,-60,...,80}{
    \pgfplotsextra{ 
        \pgfmathsetmacro\sinVis{sin(#1)/cos(#1)*sin(\azimuth)/cos(\azimuth)}
         % angle of "visibility"
        \pgfmathsetmacro\angVis{asin(min(1,max(\sinVis,-1)))}
        \coordinate (X) at (axis cs: {cos(#1)},0,{sin(#1)});
        \draw (X) arc (0:\tilt+\angVis:{100*cos(#1)}) (X) arc (0:-180+\tilt-\angVis:{100*cos(#1)});
    } }

\foreach \a in {0,20,...,359}
{ \pgfmathsetmacro{\Bound}{-60*cos(\a+45)}
    \addplot3[domain=\Bound:90, samples=45,samples y=0] ({cos(\a)*cos(x)},{sin(\a)*cos(x)},{sin(x)});
    \addplot3[domain=-90:\Bound, samples=45,samples y=0, densely dashed] ({cos(\a)*cos(x)},{sin(\a)*cos(x)},{sin(x)});
}
\end{axis}  
\end{tikzpicture}   
\end{document}

输出

在此处输入图片描述

相关内容