绘制通过球体上两点的大圆

绘制通过球体上两点的大圆

在此处输入图片描述

你好,我想用 TikZ 绘制类似下面的图像——一个通过球体上两点的大圆。

答案1

欢迎来到 TeX.SX!当然,这取决于你具体想要实现什么。如果你只是想重新创建上面的图片,你可以重新使用这个上一个答案我的。也许有点夸张,但也很适用:

\documentclass[tikz,margin=5pt]{standalone}
\usepackage{tikz}

% Style to set camera angle, like PGFPlots `view` style
\tikzset{viewport/.style 2 args={
    x={({cos(-#1)*1cm},{sin(-#1)*sin(#2)*1cm})},
    y={({-sin(-#1)*1cm},{cos(-#1)*sin(#2)*1cm})},
    z={(0,{cos(#2)*1cm})}
}}

% Convert from spherical to cartesian coordinates
\newcommand{\ToXYZ}[2]{
    {sin(#1)*cos(#2)}, % X coordinate
    {cos(#1)*cos(#2)}, % Y coordinate
    {sin(#2)}          % Z (vertical) coordinate
}

\begin{document}
\def\RotationX{-30}
\def\RotationY{-20}
\begin{tikzpicture}[scale=4]

    \path[draw] (0,0) circle (1);

    \begin{scope}[viewport={\RotationX}{\RotationY}]

        \draw[variable=\t, smooth] 
            plot[domain=90-\RotationX:-90-\RotationX] (\ToXYZ{\t}{0});
        \draw[densely dashed, variable=\t, smooth]
            plot[domain=90-\RotationX:270-\RotationX] (\ToXYZ{\t}{0});
            
        \draw[variable=\t, smooth, red] 
            plot[domain=90-\RotationY:-90-\RotationY, rotate around y=20] (\ToXYZ{0}{\t});
        \draw[densely dashed, variable=\t, smooth, red]
            plot[domain=90-\RotationY:270-\RotationY, rotate around y=20] (\ToXYZ{0}{\t});
        
        \draw[variable=\t, smooth, red, very thick] 
            plot[domain=70:0, rotate around y=20] (\ToXYZ{0}{\t});
            
        \node[circle, fill=red, inner sep=1pt, label={210:$B$}] at (\ToXYZ{0}{0}) {};
        
        \node[circle, fill=red, inner sep=1pt, label={120:$A$}, rotate around y=20] at (\ToXYZ{0}{70}) {};
        
    \end{scope}

\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容