0

I want to eventually be able to draw an open cover for the 2-d sphere. Here are some things that I would like to know how to do along the way. Any help with any of these is wonderfully appreciated.

  1. Draw a 2d sphere and a 3d epsilon ball using two difference colors. While visually, these do not need to look different, I want to eventually draw the 2d open "chart" which is the intersection of the 3d epsilon ball with the sphere.
  2. Simply draw four such "charts" on the surface of a sphere where you can see their colored intersections.

The best attempt at some of these ideas I could find was here.

1
  • I have removed the [geometry] tag, as that applies explicitly to the geometry package. Replaced by [shapes]. Commented Nov 22, 2019 at 3:17

2 Answers 2

3

Here is a partial answer based on TikZ. It is based on Alain Matthes macros and this post and requires the spath package. (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}

enter image description here

As you can see, you can shade some parts of the sphere. By changing the angles of the bounding arcs (and the color) you can add more "open subsets".

3

With asymptote you can draw such things rather easily. Here are possible first steps. I refrain from doing more since I don't know which covers you'll end up choosing, and I also don't know if you're open to asymptote. This code is to some extent stolen from this asymptote answer.

\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>

enter image description here

2
  • This is very nice. Thank you so much. I'm goin to wait a few days to see if anyone comes up with something different but barring that, I'll give you the answer, make some pictures and report back with my final result. Cheers.
    – cheyne
    Commented Dec 31, 2017 at 19:05
  • 1
    @cheyne I'm trying to do something similar with TikZ, but I got stuck here.
    – user121799
    Commented Dec 31, 2017 at 19:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .