如何绘制两个以两种不同方式切割球体的图形?

如何绘制两个以两种不同方式切割球体的图形?

这是我想在背面绘制的图形:

在此处输入图片描述

请问关于如何绘制这个,您有什么建议吗?

答案1

这是一个基于剪辑和范围(很多剪辑和范围)的 2d 解决方案。它还使用 tikz 库intersetctions来获取一些点。我做了几个宏,第一个被调用\spherepoints并在球体周围放置一些剪辑所需的坐标。这些坐标是根据曲线之间的交点定义的。它们在这里: 在此处输入图片描述

然后我制作了其他宏来绘制椭圆:完整、可见部分(剪辑)或隐藏部分(再次剪辑)。考虑到所有这些,这是(不是很短的)代码:

\documentclass[border=2mm]{standalone}
\usepackage    {tikz}
\usetikzlibrary{intersections}

\def\sr{2} % sphere radius

% some points in the sphere
\newcommand{\spherepoints}
{%
  \foreach[count=\xi]\i in {-1,1}
  {%
    \cellipse{0.25*\i*\sr}{draw=none,name path global=A-\xi}
  }
  \begin{scope}[rotate=120]
    \cellipse{0}{draw=none,name path global=A-3}
  \end{scope}
  \path [name intersections={of=A-1 and A-3,name=B}];
  \path [name intersections={of=A-2 and A-3,name=C}];
  \coordinate (P1) at (-\sr-0.1, \sr+0.1);
  \coordinate (P2) at (-\sr-0.1, 0.375*\sr);
  \coordinate (P3) at (-\sr-0.1, 0);
  \coordinate (P4) at (-\sr-0.1,-0.375*\sr);
  \coordinate (P5) at (-\sr-0.1,-\sr-0.1);
  \coordinate (Q1) at ( \sr+0.1, \sr+0.1);
  \coordinate (Q2) at ( \sr+0.1, 0.375*\sr);
  \coordinate (Q3) at ( \sr+0.1, 0);
  \coordinate (Q4) at ( \sr+0.1,-0.375*\sr);
  \coordinate (Q5) at ( \sr+0.1,-\sr-0.1);
  \coordinate (S1) at (intersection of  C-2--C-4 and Q1--Q5);
  \coordinate (R1) at (intersection of  C-2--C-4 and P1--P5);
  \coordinate (S2) at (intersection of  B-2--B-4 and Q1--Q5);
  \coordinate (R2) at (intersection of  B-2--B-4 and P1--P5);
}

% complete ellipse
\newcommand{\cellipse}[2]% height, style
{
  \pgfmathsetmacro\a{sqrt(\sr*\sr-1.5*#1*#1)}
  \pgfmathsetmacro\b{\a/sqrt(3)}
  \draw[#2] (0,#1) ellipse (\a cm and \b cm);
}

% ellipse, hidden part
\newcommand{\hellipse}[2]% height, style
{
  \pgfmathsetmacro\a{sqrt(\sr*\sr-1.5*#1*#1)}
  \pgfmathsetmacro\b{\a/sqrt(3)}
  \begin{scope}
    \clip (-\sr-0.1,1.5*#1) rectangle (\sr+0.1,\sr+0.1);
    \draw[#2] (0,#1) ellipse (\a cm and \b cm);
  \end{scope}
}

% ellipse, visible part
\newcommand{\vellipse}[2]% height, style
{
  \pgfmathsetmacro\a{sqrt(\sr*\sr-1.5*#1*#1)}
  \pgfmathsetmacro\b{\a/sqrt(3)}
  \begin{scope}
    \clip (-\sr-0.1,1.5*#1) rectangle (\sr+0.1,-\sr-0.1);
    \draw[#2] (0,#1) ellipse (\a cm and \b cm);
  \end{scope}
}


\begin{document}
\begin{tikzpicture}[line cap=round,line join=round]
% top left sphere
\begin{scope}
  \vellipse{0}{blue}
  \hellipse{0}{blue!25}
  \draw[thick] (0,0) circle (\sr);
\end{scope}
% arrow
\draw[magenta,thick,-latex] (1.3*\sr,0) -- (1.7*\sr,0);
% top right sphere, bottom half
\begin{scope}[shift={(3.5*\sr,-0.5*\sr)}]
  \cellipse{0}{thick}
  \draw[thick] (\sr,0) arc (0:-180:\sr);
\end{scope}
% top right sphere, top half
\begin{scope}[shift={(3.5*\sr,0.5*\sr)}]
  \cellipse{0}{draw=none,fill=white,fill opacity=0.75}
  \vellipse{0}{thick}
  \hellipse{0}{blue!25}
  \draw[thick] (\sr,0) arc (0:180:\sr);
\end{scope}
% bottom left sphere
\begin{scope}[shift={(0,-4*\sr)}]
  \spherepoints
  \foreach[count=\xi]\i in {-1,1}
  {%
    \vellipse{0.25*\i*\sr}{blue,name path global=A-\xi}
    \hellipse{0.25*\i*\sr}{blue!25}
  }
  \begin{scope}[rotate=120]
    \clip (R1) -- (S1) -- (S2) -- (R2) -- cycle;
    \vellipse{0}{blue}
    \hellipse{0}{blue!25}
  \end{scope}
  \draw[thick] (0,0) circle (\sr);
\end{scope}
% arrow
\draw[magenta,thick,-latex] (1.3*\sr,-4*\sr) -- (1.7*\sr,-4*\sr);
% bottom right sphere, bottom part
\begin{scope}[shift={(3.5*\sr,-5*\sr)}]
  \cellipse{-0.25*\sr}{thick}
  \clip (-\sr-0.1,-0.375*\sr) rectangle (\sr+0.1,-\sr-0.1);
  \draw[thick] (0,0) circle (\sr);
\end{scope}
% bottom right sphere, middle left part
\begin{scope}[shift={(3*\sr,-4*\sr)}]
  \spherepoints
  \cellipse{-0.25*\sr}{draw=none,fill=white,fill opacity=0.75}
  \begin{scope}
    \clip (R1) -- (S1) |- (P5) -- cycle;
    \cellipse{0.25*\sr}{thick}
  \end{scope}
  \begin{scope}
    \clip (R2) |- (0,0) |- (P4) |- (Q5) -- (S2) -- cycle;
    \cellipse{-0.25*\sr}{thick}
  \end{scope}
  \begin{scope}
    \clip (P4) rectangle (0,0);
    \hellipse{-0.25*\sr}{blue!25}
  \end{scope}
  \begin{scope}[rotate=120]
    \clip (R1) -- (S1) -- (S2) -- (R2) -- cycle;
    \cellipse{0}{thick}
  \end{scope}
  \clip (P2) -| (0,0)  |- (P4) -- cycle;
  \draw[thick] (0,0) circle (\sr);
\end{scope}
% bottom right sphere, middle right part
\begin{scope}[shift={(4*\sr,-4*\sr)}]
  \spherepoints
  \begin{scope}
    \clip (R1) -- (S1) |- (P1) -- cycle;
    \cellipse{0.25*\sr}{thick}
  \end{scope}
  \begin{scope}
    \clip (S2) -- (R2) |- (Q1) |- (0,0) |- (Q4) -- cycle;
    \cellipse{-0.25*\sr}{thick}
  \end{scope}
  \begin{scope}
    \clip (Q4) rectangle (0,0);
    \hellipse{-0.25*\sr}{blue!25}
  \end{scope}
  \begin{scope}[rotate=120]
    \clip (R1) -- (S1) -- (S2) -- (R2) -- cycle;
    \cellipse{0}{thick}
  \end{scope}
  \clip (Q2) -| (0,0)  |- (Q4) -- cycle;
  \draw[thick] (0,0) circle (\sr);
\end{scope}
% bottom right sphere, top part
\begin{scope}[shift={(3.5*\sr,-3*\sr)}]
  \spherepoints
  \vellipse{0.25*\sr}{thick,fill=white,fill opacity=0.75}
  \hellipse{0.25*\sr}{blue!25}
  \clip (P2) rectangle (Q1);
  \draw[thick] (0,0) circle (\sr);
\end{scope}
\end{tikzpicture}
\end{document}

结果如下:

在此处输入图片描述

相关内容