I have 40 squares which vertices (have integer coordinates) lie on the sphere, ``` \documentclass[12pt,a4paper]{article} \usepackage{enumitem} \begin{document} \[ (x-2)^2 + (y-4)^2 + (z-6)^2 = 225? \] \begin{enumerate}[label=\arabic*)] \item $ (-12, -1, 4), \quad (-9, 14, 8), \quad (0, 9, 20), \quad (-3, -6, 16)$. \item $ (-12, -1, 8), \quad (-9, 14, 4), \quad (0, 9, -8), \quad (-3, -6, -4)$. \item $ (-12, -1, 8), \quad (-8, 14, 11), \quad (4, 9, 20), \quad (0, -6, 17)$. \item $ (-12, 2, 1), \quad (-9, 6, 16), \quad (0, 18, 11), \quad (-3, 14, -4)$. \item $ (-12, 2, 1), \quad (-8, -1, 16), \quad (4, -10, 11), \quad (0, -7, -4)$. \item $ (-12, 2, 11), \quad (-9, 6, -4), \quad (0, 18, 1), \quad (-3, 14, 16)$. \item $ (-12, 2, 11), \quad (-8, -1, -4), \quad (4, -10, 1), \quad (0, -7, 16)$, \item $ (-12, 6, 1), \quad (-9, 2, 16), \quad (0, -10, 11), \quad (-3, -6, -4)$, \item $ (-12, 6, 1), \quad (-8, 9, 16), \quad (4, 18, 11), \quad (0, 15, -4)$, \item $ (-12, 6, 11), \quad (-9, 2, -4), \quad (0, -10, 1), \quad (-3, -6, 16)$. \item $ (-12, 6, 11), \quad (-8, 9, -4), \quad (4, 18, 1), \quad (0, 15, 16)$. \item $ (-12, 9, 4), \quad (-9, -6, 8), \quad (0, -1, 20), \quad (-3, 14, 16)$. \item $ (-12, 9, 8), \quad (-9, -6, 4), \quad (0, -1, -8), \quad (-3, 14, -4)$. \item $ (-12, 9, 8), \quad (-8, -6, 11), \quad (4, -1, 20), \quad (0, 14, 17)$. \item $ (-9, 2, -4), \quad (0, -10, 11), \quad (13, 6, 16), \quad (4, 18, 1)$. \item $ (-9, 2, 16), \quad (0, -10, 1), \quad (13, 6, -4), \quad (4, 18, 11)$. \item $ (-9, 6, -4), \quad (0, 18, 11), \quad (13, 2, 16), \quad (4, -10, 1)$. \item $ (-9, 6, 16), \quad (0, 18, 1), \quad (13, 2, -4), \quad (4, -10, 11)$. \item $ (-8, -7, 8), \quad (-3, 2, 20), \quad (12, -1, 16), \quad (7, -10, 4)$. \item $ (-8, -6, 11), \quad (-3, 6, 20), \quad (12, 2, 17), \quad (7, -10, 8)$. \item $ (-8, -1, -4), \quad (-3, 18, 4), \quad (12, 9, 16), \quad (7, -10, 8)$. \item $ (-8, -1, -4), \quad (0, 18, 1), \quad (12, 9, 16), \quad (4, -10, 11)$. \item $ (-8, -1, 16), \quad (-3, -10, 4), \quad (12, -7, 8), \quad (7, 2, 20)$. \item $ (-8, -1, 16), \quad (-3, 18, 8), \quad (12, 9, -4), \quad (7, -10, 4)$. \item $ (-8, -1, 16), \quad (0, 18, 11), \quad (12, 9, -4), \quad (4, -10, 1)$. \item $ (-8, 2, -5), \quad (-3, 18, 8), \quad (12, 6, 17), \quad (7, -10, 4)$. \item $ (-8, 2, 17), \quad (-3, -10, 8), \quad (12, -6, 11), \quad (7, 6, 20)$. \item $ (-8, 2, 17), \quad (-3, 18, 4), \quad (12, 6, -5), \quad (7, -10, 8)$. \item $ (-8, 6, -5), \quad (-3, -10, 8), \quad (12, 2, 17), \quad (7, 18, 4)$. \item $ (-8, 6, 17), \quad (-3, -10, 4), \quad (12, 2, -5), \quad (7, 18, 8)$. \item $ (-8, 6, 17), \quad (-3, 18, 8), \quad (12, 14, 11), \quad (7, 2, 20)$. \item $ (-8, 9, -4), \quad (-3, -10, 4), \quad (12, -1, 16), \quad (7, 18, 8)$. \item $ (-8, 9, -4), \quad (0, -10, 1), \quad (12, -1, 16), \quad (4, 18, 11)$. \item $ (-8, 9, 16), \quad (-3, -10, 8), \quad (12, -1, -4), \quad (7, 18, 4)$. \item $ (-8, 9, 16), \quad (-3, 18, 4), \quad (12, 15, 8), \quad (7, 6, 20)$. \item $ (-8, 9, 16), \quad (0, -10, 11), \quad (12, -1, -4), \quad (4, 18, 1)$. \item $ (-8, 14, 11), \quad (-3, 2, 20), \quad (12, 6, 17), \quad (7, 18, 8)$. \item $ (-8, 15, 8), \quad (-3, 6, 20), \quad (12, 9, 16), \quad (7, 18, 4)$. \item $ (0, -1, 20), \quad (4, 14, 17), \quad (16, 9, 8), \quad (12, -6, 11)$. \item $ (0, 9, 20), \quad (4, -6, 17), \quad (16, -1, 8), \quad (12, 14, 11)$. \end{enumerate} \end{document} ``` How can I draw one or some that squares?
This may be a starting point. The challenge seems to be to draw great circle arcs on a sphere in such a way that visible and hidden stretches get distinguished. Some time ago I posted a code that does that on TeX.SE. This code got resurrected here, and can definitely get more streamlined. But it seems to work at least. ``` \documentclass[tikz,border=3mm]{standalone} \usepackage{tikz-3dplot} \usetikzlibrary{3dtools} \makeatletter \pgfmathdeclarefunction{isfore}{3}{% \begingroup% \pgfkeys{/pgf/fpu,/pgf/fpu/output format=fixed}% \pgfmathparse{% sign(((\the\pgf@yx)*(\the\pgf@zy)-(\the\pgf@yy)*(\the\pgf@zx))*(#1)+ ((\the\pgf@zx)*(\the\pgf@xy)-(\the\pgf@xx)*(\the\pgf@zy))*(#2)+ ((\the\pgf@xx)*(\the\pgf@yy)-(\the\pgf@yx)*(\the\pgf@xy))*(#3))}% \pgfmathsmuggle\pgfmathresult\endgroup% }% \tikzset{3d/great circle arc/.cd, theta1/.initial=0,phi1/.initial=0,theta2/.initial=0,phi2/.initial=30, r/.initial=R,fore/.style={draw=white,semithick},back/.style={draw=gray,very thin}} \tikzset{pics/3d/great circle arc/.style={code={% \tikzset{3d/great circle arc/.cd,#1}% \def\pv##1{\pgfkeysvalueof{/tikz/3d/great circle arc/##1}}% % Cartesian coordinates of the first point (A) \pgfmathsetmacro\pgfutil@tempAx{\pv{r}*cos(\pv{theta1})*cos(\pv{phi1})}% \pgfmathsetmacro\pgfutil@tempAy{\pv{r}*cos(\pv{theta1})*sin(\pv{phi1})}% \pgfmathsetmacro\pgfutil@tempAz{\pv{r}*sin(\pv{theta1})}% % Cartesian coordinates of the second point (B) \pgfmathsetmacro\pgfutil@tempBx{\pv{r}*cos(\pv{theta2})*cos(\pv{phi2})}% \pgfmathsetmacro\pgfutil@tempBy{\pv{r}*cos(\pv{theta2})*sin(\pv{phi2})}% \pgfmathsetmacro\pgfutil@tempBz{\pv{r}*sin(\pv{theta2})}% % cross product C=AxB \pgfmathsetmacro@td@FPU\pgfutil@tempCx{(\pgfutil@tempAy)*(\pgfutil@tempBz)-(\pgfutil@tempBy)*(\pgfutil@tempAz)}% \pgfmathsetmacro@td@FPU\pgfutil@tempCy{(\pgfutil@tempAz)*(\pgfutil@tempBx)-(\pgfutil@tempBz)*(\pgfutil@tempAx)}% \pgfmathsetmacro@td@FPU\pgfutil@tempCz{(\pgfutil@tempAx)*(\pgfutil@tempBy)-(\pgfutil@tempBx)*(\pgfutil@tempAy)}% % normalize C to have length r \pgfmathsetmacro@td@FPU\pgfutil@tempa{sqrt((\pgfutil@tempCx)*(\pgfutil@tempCx)+(\pgfutil@tempCy)*(\pgfutil@tempCy)+(\pgfutil@tempCz)*(\pgfutil@tempCz))/\pv{r}}% \pgfmathsetmacro@td@FPU\pgfutil@tempCx{\pgfutil@tempCx/\pgfutil@tempa}% \pgfmathsetmacro@td@FPU\pgfutil@tempCy{\pgfutil@tempCy/\pgfutil@tempa}% \pgfmathsetmacro@td@FPU\pgfutil@tempCz{\pgfutil@tempCz/\pgfutil@tempa}% % angle between A and B \pgfmathsetmacro@td@FPU\pgfutil@tempAdotB{((\pgfutil@tempAx)*(\pgfutil@tempBx)+ (\pgfutil@tempAy)*(\pgfutil@tempBy)+(\pgfutil@tempAz)*(\pgfutil@tempBz))/(\pv{r}*\pv{r})}% \pgfmathsetmacro@td@FPU\pgfutil@tempangle{acos(\pgfutil@tempAdotB)}% % cross product D=AxC \pgfmathsetmacro@td@FPU\pgfutil@tempDx{(\pgfutil@tempAy)*(\pgfutil@tempCz)-(\pgfutil@tempCy)*(\pgfutil@tempAz)}% \pgfmathsetmacro@td@FPU\pgfutil@tempDy{(\pgfutil@tempAz)*(\pgfutil@tempCx)-(\pgfutil@tempCz)*(\pgfutil@tempAx)}% \pgfmathsetmacro@td@FPU\pgfutil@tempDz{(\pgfutil@tempAx)*(\pgfutil@tempCy)-(\pgfutil@tempCx)*(\pgfutil@tempAy)}% \pgfmathsetmacro@td@FPU\pgfutil@tempa{sqrt((\pgfutil@tempDx)*(\pgfutil@tempDx)+(\pgfutil@tempDy)*(\pgfutil@tempDy)+(\pgfutil@tempDz)*(\pgfutil@tempDz))/\pv{r}}% \pgfmathsetmacro@td@FPU\pgfutil@tempDx{\pgfutil@tempDx/\pgfutil@tempa}% \pgfmathsetmacro@td@FPU\pgfutil@tempDy{\pgfutil@tempDy/\pgfutil@tempa}% \pgfmathsetmacro@td@FPU\pgfutil@tempDz{\pgfutil@tempDz/\pgfutil@tempa}% %\typeout{A=(\pgfutil@tempAx,\pgfutil@tempAy,\pgfutil@tempAz),B=(\pgfutil@tempBx,\pgfutil@tempBy,\pgfutil@tempBz),C=(\pgfutil@tempCx,\pgfutil@tempCy,\pgfutil@tempCz)} %\typeout{\pgfutil@tempAdotB,\pgfutil@tempangle} \edef\pgfutil@tempa{0}% \pgfmathtruncatemacro{\pgfutil@tempd}{isfore(\pgfutil@tempAx,\pgfutil@tempAy,\pgfutil@tempAz)}% \ifnum\pgfutil@tempd=-1\relax \edef\pgfutil@templsthidcoords{(\pgfutil@tempAx,\pgfutil@tempAy,\pgfutil@tempAz)}% \edef\pgfutil@templstviscoords{}% \else \edef\pgfutil@templsthidcoords{}% \edef\pgfutil@templstviscoords{(\pgfutil@tempAx,\pgfutil@tempAy,\pgfutil@tempAz)}% \fi \pgfmathtruncatemacro\pgfutil@tempb{acos(\pgfutil@tempAdotB)}% \pgfmathtruncatemacro\pgfutil@tempc{sign(\pgfutil@tempb)}% \loop \pgfmathsetmacro{\tmpx}{cos(\pgfutil@tempa)*\pgfutil@tempAx-\pgfutil@tempc*sin(\pgfutil@tempa)*\pgfutil@tempDx}% \pgfmathsetmacro{\tmpy}{cos(\pgfutil@tempa)*\pgfutil@tempAy-\pgfutil@tempc*sin(\pgfutil@tempa)*\pgfutil@tempDy}% \pgfmathsetmacro{\tmpz}{cos(\pgfutil@tempa)*\pgfutil@tempAz-\pgfutil@tempc*sin(\pgfutil@tempa)*\pgfutil@tempDz}% \pgfmathtruncatemacro{\pgfutil@tempd}{isfore(\tmpx,\tmpy,\tmpz)}% \ifnum\pgfutil@tempd=-1\relax \edef\pgfutil@templsthidcoords{\pgfutil@templsthidcoords\space(\tmpx,\tmpy,\tmpz)}% \else \edef\pgfutil@templstviscoords{\pgfutil@templstviscoords\space(\tmpx,\tmpy,\tmpz)}% \fi \edef\pgfutil@tempa{\the\numexpr\pgfutil@tempa+1}% \ifnum\pgfutil@tempa<\the\numexpr\pgfutil@tempc*\pgfutil@tempb\relax \repeat \pgfmathtruncatemacro{\pgfutil@tempd}{isfore(\pgfutil@tempBx,\pgfutil@tempBy,\pgfutil@tempBz)}% \ifnum\pgfutil@tempd=-1\relax \edef\pgfutil@templsthidcoords{\pgfutil@templsthidcoords\space(\pgfutil@tempBx,\pgfutil@tempBy,\pgfutil@tempBz)}% \else \edef\pgfutil@templstviscoords{\pgfutil@templstviscoords\space(\pgfutil@tempBx,\pgfutil@tempBy,\pgfutil@tempBz)}% \fi \ifx\pgfutil@templsthidcoords\pgfutil@empty% \else \draw[3d/hidden] plot coordinates {\pgfutil@templsthidcoords};% \fi \ifx\pgfutil@templstviscoords\pgfutil@empty% \else \draw[3d/visible] plot coordinates {\pgfutil@templstviscoords};% \fi }}} \makeatother \begin{document} \foreach \Angle in {5,15,...,355} {\begin{tikzpicture}[declare function={R=15;},scale=0.3] \begin{scope}[3d/install view={phi=\Angle,theta=70}] \path (2,4,6) coordinate (O') (-12,-1,4) coordinate (A) (-9,14,8) coordinate (B) (0,9,20) coordinate (C) (-3,-6,16) coordinate (D); \path[3d/screen coords,shift={(O')}, use as bounding box] (-R-1,-R-1) rectangle (R+1,R+1); \shade[3d/screen coords,ball color = black!80, transform canvas={rotate around={-35:(O')}}] (O') circle[radius=R]; \path foreach \X in {A,B,C,D} {[3d coordinate={(\X')=(\X)-(O')}]%(\X) node[circle,draw,blue]{} }; \tikzset{get spherical angles/.code={% \expandafter\pgfmathsetmacro\csname lat##1\endcsname{asin(TD("(##1')o(0,0,1)")/R)} \expandafter\pgfmathsetmacro\csname az##1\endcsname{atan2(TD("(##1')o(0,1,0)"),TD("(##1')o(1,0,0)"))}}} \tikzset{get spherical angles/.list={A,B,C,D}} \path[shift={(O')},transform shape, 3d/visible/.append style={yellow}, 3d/hidden/.append style={yellow}] pic{3d/great circle arc={theta1={\latA},phi1={\azA},theta2={\latB},phi2={\azB}}} pic{3d/great circle arc={theta1={\latB},phi1={\azB},theta2={\latC},phi2={\azC}}} pic{3d/great circle arc={theta1={\latC},phi1={\azC},theta2={\latD},phi2={\azD}}} pic{3d/great circle arc={theta1={\latD},phi1={\azD},theta2={\latA},phi2={\azA}}}; % \end{scope} \end{tikzpicture}} \end{document} ``` ![ani.gif](/image?hash=a59e12c1aa1dcef0cd10a9d12aa6563219ac05712ff30f13e2682b4b2d0dcd41)