3D 球体上的圆弧

3D 球体上的圆弧

我正在尝试使用 tikz 来绘制它: 草图

到目前为止我已经了解了以下内容: tikz 图

我的(尴尬的)代码:

\documentclass[crop,tikz]{standalone}
\usepackage{tikz-3dplot}
\usepackage{marvosym}

\begin{document}
    \tdplotsetmaincoords{70}{120}
    \begin{tikzpicture}[tdplot_main_coords, scale=2]

        % Earth
        \tdplotsetrotatedcoords{20}{80}{0}
        \draw [ball color=white,very thin,tdplot_rotated_coords] (0,0,0) circle (1) ;
        % Equator
        \draw [dashed] (0,0,0) circle (1) ;

        % Axis
        \draw[thick,->] (0,0,0) -- (3,0,0) node[anchor=north east]{\Aries};
        \draw[thick, dashed, ->] (0,0,0) -- (0,0,1.5) node[anchor=south]{$N$};

        % Omega
        \pgfmathsetmacro{\bx}{1}
        \pgfmathsetmacro{\by}{1}
        \pgfmathsetmacro{\bz}{0}

        \draw[thick] (0,0,0) -- (\bx,\by,\bz) node[anchor=north]{};

        \tdplotdefinepoints(0,0,0)(1,0,0)(\bx,\by,\bz);
        \tdplotdrawpolytopearc[red, thick]{0.5}{anchor=north}{$\Omega$}


    \end{tikzpicture}
\end{document}

目前,我很难添加其他圆弧,因为 2d 圆真的让我很困惑。在“球体”上绘制圆弧的最简单方法是什么?

答案1

只是给你一个开始。实际上,Alain Matthes 已经完成了这个答案

\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{calc}
\tikzset{%
    add/.style args={#1 and #2}{
        to path={%
 ($(\tikztostart)!-#1!(\tikztotarget)$)--($(\tikztotarget)!-#2!(\tikztostart)$)%
  \tikztonodes},add/.default={.2 and .2}}
}  


\tikzset{%
  mark coordinate/.style={inner sep=0pt,outer sep=0pt,minimum size=2pt,
    fill=black,circle}%
}

\newcommand\pgfmathsinandcos[3]{%
  \pgfmathsetmacro#1{sin(#3)}%
  \pgfmathsetmacro#2{cos(#3)}%
}
\newcommand\LongitudePlane[2][current plane]{%
  \pgfmathsinandcos\sinEl\cosEl{\Elevation} % elevation
  \pgfmathsinandcos\sint\cost{#2} % azimuth
  \tikzset{#1/.estyle={cm={\cost,\sint*\sinEl,0,\cosEl,(0,0)}}}
}
\newcommand\LatitudePlane[2][current plane]{%
  \pgfmathsinandcos\sinEl\cosEl{\Elevation} % elevation
  \pgfmathsinandcos\sint\cost{#2} % latitude
  \pgfmathsetmacro\ydelta{\cosEl*\sint}
  \tikzset{#1/.estyle={cm={\cost,0,0,\cost*\sinEl,(0,\ydelta)}}} %
}
\newcommand\DrawLongitudeCircle[1]{
  \LongitudePlane{#1}
  \tikzset{current plane/.prefix style={scale=\R}}
  \pgfmathsetmacro\angVis{atan(sin(#1)*cos(\Elevation)/sin(\Elevation))} %
  \draw[current plane,thin,black]  (\angVis:1)     arc (\angVis:\angVis+180:1);
  \draw[current plane,thin,dashed] (\angVis-180:1) arc (\angVis-180:\angVis:1);
}%

\newcommand\DrawLatitudeCircle[1]{
  \LatitudePlane{#1}
  \tikzset{current plane/.prefix style={scale=\R}}
  \pgfmathsetmacro\sinVis{sin(#1)/cos(#1)*sin(\Elevation)/cos(\Elevation)}
  \pgfmathsetmacro\angVis{asin(min(1,max(\sinVis,-1)))}
  \draw[current plane,thin,black] (\angVis:1) arc (\angVis:-\angVis-180:1);
  \draw[current plane,thin,dashed] (180-\angVis:1) arc (180-\angVis:\angVis:1);
}%

\newcommand\DrawPointOnSphere[3]{%
\pgfmathsinandcos\sinLoM\cosLoM{#1}  
\pgfmathsinandcos\sinLaM\cosLaM{#2}
} 


\begin{document}
  \begin{tikzpicture}
  \def\R{4} % sphere radius
  \def\Elevation{15} % elevation angle
  \def\angleLongitudeP{-110} % longitude of point P
  \def\angleLongitudeQ{-45} % longitude of point Q
  \def\angleLatitudeQ{30} % latitude  Q    ; 0 latitude of P 
  \def\angleLongitudeA{-20} % longitude of point A

  \pgfmathsetmacro\H{\R*cos(\Elevation)} % distance to north pole
  \LongitudePlane[PLongitudePlane]{\angleLongitudeP}
  \LongitudePlane[QLongitudePlane]{\angleLongitudeQ}
  \LongitudePlane[ALongitudePlane]{\angleLongitudeA}
  \LatitudePlane[Equator]{0} 

  \fill[ball color=white!10] (0,0) circle (\R); % 3D lighting effect
  \coordinate (O) at (0,0);
  \coordinate[] (N) at (0,\H);
  \coordinate[] (S) at (0,-\H);

  %setup coordinates P and Q
  \path[ALongitudePlane] (0:\R) coordinate (A);
  \path[ALongitudePlane] (32.5:\R) coordinate (A'); 
  \path[ALongitudePlane] (122.5:\R) coordinate (N');  
  \path[PLongitudePlane] (0:\R) coordinate (P);
  \path[QLongitudePlane] (\angleLatitudeQ:\R) coordinate (Q);
  \path[QLongitudePlane] (0:\R) coordinate (B);
  \draw [dashed] (O) --  (N) ;  

\foreach \v in {N} {\coordinate[mark coordinate] (\v) at (\v);
\node [above] at (\v) {\v};} 
 \begin{scope}[ x={(P)}, y={(A')}, z={(N')}]     
          \draw[very thick,blue] ( -60:1) arc (-60:120:1) ;
          \draw[very thick,blue,-latex] ( -60:1) arc (-60:60:1) ;
 \end{scope} 
   \draw[red,very thick,Equator] (180:\R) arc (180:360:\R);  

\end{tikzpicture}   
\end{document}  

在此处输入图片描述

更新:对以下内容做了一些小补充:这个帖子. 你可以通过以下方式来做:

\documentclass[tikz,border=3.14mm]{standalone}
\usetikzlibrary{calc,fadings,decorations.pathreplacing,decorations.markings,shadings}

\newcommand\pgfmathsinandcos[3]{%
  \pgfmathsetmacro#1{sin(#3)}%
  \pgfmathsetmacro#2{cos(#3)}%
}
\newcommand\LongitudePlane[3][current plane]{%
  \pgfmathsinandcos\sinEl\cosEl{#2} % elevation
  \pgfmathsinandcos\sint\cost{#3} % azimuth
  \tikzset{#1/.style={cm={\cost,\sint*\sinEl,0,\cosEl,(0,0)}}}
}

\newcommand\LatitudePlane[3][current plane]{%
  \pgfmathsinandcos\sinEl\cosEl{#2} % elevation
  \pgfmathsinandcos\sint\cost{#3} % latitude
  \pgfmathsetmacro\yshift{\RadiusSphere*\cosEl*\sint}
  \tikzset{#1/.style={cm={\cost,0,0,\cost*\sinEl,(0,\yshift)}}} %
}
\newcommand\NewLatitudePlane[4][current plane]{%
  \pgfmathsinandcos\sinEl\cosEl{#3} % elevation
  \pgfmathsinandcos\sint\cost{#4} % latitude
  \pgfmathsetmacro\yshift{#2*\cosEl*\sint}
  \tikzset{#1/.style={cm={\cost,0,0,\cost*\sinEl,(0,\yshift)}}} %
}
\newcommand\DrawLongitudeCircle[2][1]{
  \LongitudePlane{\angEl}{#2}
  \tikzset{current plane/.prefix style={scale=#1}}
   % angle of "visibility"
  \pgfmathsetmacro\angVis{atan(sin(#2)*cos(\angEl)/sin(\angEl))} %
  \draw[current plane] (\angVis:1) arc (\angVis:\angVis+180:1);
  \draw[current plane,opacity=0.4] (\angVis-180:1) arc (\angVis-180:\angVis:1);
}
\newcommand\DrawLongitudeArc[4][black]{
  \LongitudePlane{\angEl}{#2}
  \tikzset{current plane/.prefix style={scale=1}}
  \pgfmathsetmacro\angVis{atan(sin(#2)*cos(\angEl)/sin(\angEl))} %
  \pgfmathsetmacro\angA{mod(max(\angVis,#3),360)} %
  \pgfmathsetmacro\angB{mod(min(\angVis+180,#4),360} %
  \draw[current plane,#1,opacity=0.4] (#3:\RadiusSphere) arc (#3:#4:\RadiusSphere);
  \draw[current plane,#1]  (\angA:\RadiusSphere) arc (\angA:\angB:\RadiusSphere);
}%
\newcommand\DrawLatitudeCircle[2][1]{
  \LatitudePlane{\angEl}{#2}
  \tikzset{current plane/.prefix style={scale=#1}}
  \pgfmathsetmacro\sinVis{sin(#2)/cos(#2)*sin(\angEl)/cos(\angEl)}
  % angle of "visibility"
  \pgfmathsetmacro\angVis{asin(min(1,max(\sinVis,-1)))}
  \draw[current plane] (\angVis:1) arc (\angVis:-\angVis-180:1);
  \draw[current plane,opacity=0.4] (180-\angVis:1) arc (180-\angVis:\angVis:1);
}

\newcommand\DrawLatitudeArc[4][black]{
  \LatitudePlane{\angEl}{#2}
  \tikzset{current plane/.prefix style={scale=1}}
  \pgfmathsetmacro\sinVis{sin(#2)/cos(#2)*sin(\angEl)/cos(\angEl)}
  % angle of "visibility"
  \pgfmathsetmacro\angVis{asin(min(1,max(\sinVis,-1)))}
  \pgfmathsetmacro\angA{max(min(\angVis,#3),-\angVis-180)} %
  \pgfmathsetmacro\angB{min(\angVis,#4)} %
  \draw[current plane,#1,opacity=0.4] (#3:\RadiusSphere) arc (#3:#4:\RadiusSphere);
  \draw[current plane,#1] (\angA:\RadiusSphere) arc (\angA:\angB:\RadiusSphere);
}

%% document-wide tikz options and styles

\tikzset{%
  >=latex, % option for nice arrows
  inner sep=0pt,%
  outer sep=2pt,%
  mark coordinate/.style={inner sep=0pt,outer sep=0pt,minimum size=3pt,
    fill=black,circle}%
}

\begin{document}

\begin{tikzpicture} % "THE GLOBE" showcase
\def\RadiusSphere{4} % sphere radius
\def\angEl{20} % elevation angle
\def\angAz{-20} % azimuth angle

\shade[ball color = gray!40, opacity = 0.5] (0,0) circle (\RadiusSphere);

\pgfmathsetmacro\H{\RadiusSphere*cos(\angEl)} % distance to north pole
\coordinate (O) at (0,0);
\node[circle,draw,black,scale=0.3] at (0,0) {};
\draw[right] node at (0,0){O};
\coordinate[mark coordinate] (N) at (0,\H);
\draw[left] node at (0,\H){N};
\coordinate[mark coordinate] (S) at (0,-\H);
\draw[left] node at (0,-\H){S};
\draw[thick, dashed, black](N)--(S);

\tikzset{
    every path/.style={
        color=green!50!black
    }
}
\DrawLatitudeCircle[\RadiusSphere]{0}
\tikzset{
    every path/.style={
        color=black
    }
}




\def\arcrad{2}
\NewLatitudePlane[equator]{\RadiusSphere}{\angEl}{00};

%\draw[-,dashed] (Oprime) -- (O) -- (Pprime);

%%%%%%%%
  \def\angleLongitudeP{-110} % longitude of point P
  \def\angleLongitudeQ{-45} % longitude of point Q
  \def\angleLatitudeQ{30} % latitude  Q    ; 0 latitude of P 
  \def\angleLongitudeA{-20} % longitude of point A

  \LongitudePlane[PLongitudePlane]{\angleLongitudeP}{\angAz}
  \LongitudePlane[QLongitudePlane]{\angleLongitudeQ}{\angAz}
  \LongitudePlane[ALongitudePlane]{\angleLongitudeA}{\angAz}

  \path[ALongitudePlane] (32.5:\RadiusSphere) coordinate (A'); 
  \path[ALongitudePlane] (122.5:\RadiusSphere) coordinate (N');  
  \path[PLongitudePlane] (00:\RadiusSphere) coordinate (P);

 \begin{scope}[ x={(P)}, y={(A')}, z={(N')}]     
          \draw[very thick,blue] (-135:0.75) arc (-135:45:0.75) ;
          \draw[very thick,blue,-latex] (-135:0.75) arc (-135:-15:0.75) ;
          \coordinate (Q) at (-60:0.75);
 \end{scope} 
 \draw (Q) -- (O);
 \path[equator] (135:{2*\RadiusSphere}) coordinate (X);
 \draw[-latex] (O) -- (X) node[below]{$x$};
 \draw[equator,-,red] (135:\arcrad) arc (135:100:\arcrad)
 node[pos=0.7,above]{$\Omega$};

\end{tikzpicture}

\end{document}

在此处输入图片描述

笔记:钛Z 没有真正的 3D 引擎。因此,你需要“手动”完成许多事情。当然,在 3 维空间中,事情总是比 2 维空间中更棘手一些。

相关内容