球体的交点

球体的交点

我希望最终能够绘制二维球体的开覆盖。以下是我想知道如何在此过程中完成的一些事情。任何帮助都将不胜感激。

  1. 使用两种不同的颜色绘制一个 2d 球体和一个 3d epsilon 球体。虽然从视觉上看,它们不需要看起来不同,但我最终想绘制 2d 开放“图表”,即 3d epsilon 球体与球体的交点。
  2. 只需在球体的表面上画出四张这样的“图表”,您就可以看到它们的彩色交叉点。

我能找到的这些想法中最好的尝试是这里

答案1

以下是基于 Ti 的部分答案Z.它基于Alain Matthes 宏这个帖子并要求spath 包。 (pdflatex spath.dtx

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shadings}
\usepackage{spath} % from https://tex.stackexchange.com/a/26664/121799
\usetikzlibrary{calc,fadings,decorations.pathreplacing,shadings}
\usepackage{verbatim}

\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\ClipLongitudeArc[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} %
  \path[save path=\tmppathI,current plane,#1,opacity=0.4] (#3:\RadiusSphere) arc (#3:#4:\RadiusSphere);
  \path[save path=\tmppathII,current plane,#1]  (\angA:\RadiusSphere) arc (\angA:\angB:\RadiusSphere);
}%

\newcommand\ClipLongitudeArcReverse[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} %
  \path[save path=\tmppathI,current plane,#1,opacity=0.4] (#4:\RadiusSphere) arc (#4:#3:\RadiusSphere);
  \path[save path=\tmppathII,current plane,#1]  (\angB:\RadiusSphere) arc (\angB:\angA:\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);
}

\newcommand\ClipLatitudeArc[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)} %
  \path[save path=\tmppathI,current plane,#1,opacity=0.4] (#3:\RadiusSphere) arc (#3:#4:\RadiusSphere);
  \path[save path=\tmppathII,current plane,#1] (\angA:\RadiusSphere) arc (\angA:\angB:\RadiusSphere);
}

\newcommand\ClipLatitudeArcReverse[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)} %
  \path[save path=\tmppathI,current plane,#1,opacity=0.4] (#4:\RadiusSphere) arc (#4:#3:\RadiusSphere);
  \path[save path=\tmppathII,current plane,#1] (\angB:\RadiusSphere) arc (\angB:\angA:\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);

\tikzset{
    every path/.style={
        color=black
    }
}

\ClipLatitudeArc[blue]{40}{-140}{-30}
\pgfoonew \patha=new spath(\tmppathI)
\pgfoonew \pathb=new spath(\tmppathII)
\ClipLongitudeArc[blue]{-30}{40}{-40} 
\pgfoonew \pathc=new spath(\tmppathI)
\pgfoonew \pathd=new spath(\tmppathII)
\ClipLatitudeArc[blue]{-40}{-30}{-140}
\pgfoonew \pathe=new spath(\tmppathI)
\pgfoonew \pathf=new spath(\tmppathII)
\ClipLongitudeArc[blue]{-140}{-30}{40}
\pgfoonew \pathg=new spath(\tmppathI)
\pgfoonew \pathh=new spath(\tmppathII)

\patha.concatenate with lineto(,\pathc)
\patha.concatenate with lineto(,\pathe)
\patha.concatenate with lineto(,\pathg)
\patha.close()

\patha.use path with tikz(line width=1pt,draw=black,fill=blue,path fading=south)

\end{tikzpicture}
\end{document}

在此处输入图片描述

如您所见,您可以为球体的某些部分着色。通过更改边界弧的角度(和颜色),您可以添加更多“开放子集”。

答案2

使用渐近线,您可以相当轻松地绘制此类内容。以下是可能的第一步。我没有做更多,因为我不知道您最终会选择哪些封面,也不知道您是否愿意使用渐近线。此代码在某种程度上是从这个渐近线答案

\documentclass{standalone}
\usepackage[inline]{asymptote}

\begin{document}
\begin{asy}
settings.prc=false;
settings.tex="pdflatex";
settings.render=0;

import three;
size(200); size3(200);

currentprojection=orthographic(
camera=(5.4290316601351,2.94352790610013,1.1108527434919),up=Z,target=O,zoom=0.7);
real r=1;

triple A1,B1,C1,D1;
A1=dir(80.0,340.0);
B1=dir(80.0,80.0);
C1=dir(20.0,80.0);
D1=dir(20.0,340.0);

guide3 AB1=arc(O,A1,B1,CCW);
guide3 BC1=arc(O,B1,C1,CCW);
guide3 CD1=arc(O,C1,D1,CCW);
guide3 DA1=arc(O,D1,A1,CCW);

radialshade(project(circle((0,0,0),1
,currentprojection.camera-currentprojection.target))
,rgb(0.79,0.79,0.85)+opacity(0.5), project(O), 1.0
,rgb(0.99,0.99,0.85)+opacity(0.5), project(O), 0.2
);

guide3 g=AB1--BC1--CD1--DA1--cycle;
fill(project(g),rgb(1,1,0.8)+opacity(0.5));

draw(arc(O,A1,B1,CCW),blue+1bp);
draw(arc(O,B1,C1,CCW),blue+1bp);
draw(arc(O,C1,D1,CCW),blue+1bp);
draw(arc(O,D1,A1,CCW),blue+1bp);

dot(A1,blue); dot(B1,blue); dot(C1,blue); dot(D1,blue);

//label("$A$",project(A1),SW);
//label("$B$",project(B1),N);
//label("$C$",project(C1),SE);    

triple A2,B2,C2,D2;
A2=dir(140.0,-20.0);
B2=dir(140.0,80.0);
C2=dir(70.0,80.0);
D2=dir(70.0,-20.0);

guide3 AB2=arc(O,A2,B2,CCW);
guide3 BC2=arc(O,B2,C2,CCW);
guide3 CD2=arc(O,C2,D2,CCW);
guide3 DA2=arc(O,D2,A2,CCW);

guide3 AD2=arc(O,A1,D2,CCW);
guide3 CB2=arc(O,C2,B1,CCW);
guide3 BA1=arc(O,B1,A1,CCW);
guide3 DC2=arc(O,D2,C2,CCW);

radialshade(project(circle((0,0,0),1
,currentprojection.camera-currentprojection.target))
,rgb(0.79,0.79,0.85)+opacity(0.5), project(O), 1.0
,rgb(0.99,0.99,0.85)+opacity(0.5), project(O), 0.2
);

guide3 g=AB2--BC2--CD2--DA2--cycle;
fill(project(g),rgb(1,0.8,1)+opacity(0.5));

guide3 g=BA1--AD2--DC2--CB2--cycle;
fill(project(g),rgb(1,0.8,0.8)+opacity(0.5));


draw(arc(O,A2,B2,CCW),red+1bp);
draw(arc(O,B2,C2,CCW),red+1bp);
draw(arc(O,C2,D2,CCW),red+1bp);
draw(arc(O,D2,A2,CCW),red+1bp);

dot(A2,red); dot(B2,red); dot(C2,red); dot(D2,red);
//label("$A1$",project(A1),SW);
//label("$B1$",project(B1),SW);
//label("$D2$",project(D2),SW);
//label("$C2$",project(C2),SW);
\end{asy}
\end{document}
% process with pdflatex <file>, then asy <file>-1, and again pdflatex <file>

在此处输入图片描述

相关内容