%% $Id: pst-ellipsoid-doc.tex 1288 2026-06-09 08:05:31Z herbert $
\DocumentMetadata{lang=en}
\documentclass[11pt,english,BCOR10mm,DIV14,bibliography=totoc,parskip=false,
   smallheadings, headexclude,footexclude,twoside]{pst-doc}

\usepackage{pst-solides3d}
\let\pstFV\fileversion
\usepackage{pst-plot}

\addbibresource{\jobname.bib}

\usepackage{enumitem,xltabular,hvindex,hvlogos,minted-code,hvextern}
\setkeys{hv}{moveToExampleDir,ExampleDir=./exa-pdf,
  %showFilename=true,shiftFN=-30pt,
  force=false}

\setlist{nosep}

\usepackage{makeidx}
\makeindex

\def\bgImage{\input{\jobname-exa01}}


\title{Ellipsoids with PSTricks}
\author{Manuel Luque \\Herbert Voß}


\begin{document}
\settitle

\tableofcontents


\section{Introduction}

\inputCodeblockA[title=Code for the title image (exa01)]{\jobname-exa01.tex}

\LPack{pst-ellipsoid} is a complementary package for PSTricks for 
representing ellipsoid solids in 3D.~\cite{wiki} The main package \LPack{pst-solides3d}
has the
new keyword \Lkeyset{object=ellipsoid}. This object includes the predefined parameters
\LKeyword{a=3}, \LKeyword{b=2}, \LKeyword{c=1}. These values are given as an example; 
they are the \Index{semi-axes} of the ellipsoid, they will be automatically
placed in the order $a > b > c$ and \LKeyword{base=0 360 -90 90}
 which allows us to describe the ellipsoid in \Index{spherical coordinates} 
$[\theta_1\ \theta_2\ \varphi_1\ \varphi_2]$.~\cite{wiki}

\[
\begin{pmatrix}x\\y\\z\end{pmatrix} = 
\begin{pmatrix}
a\cos\theta\cos\varphi\\
b\sin\theta\cos\varphi\\
c\sin\varphi
\end{pmatrix}
\]

The deafult values are $a1=3$, $b1=2$, $c1=1$. Predifined variables are

\renewcommand\eqdef{\ensuremath{\mathrel{\stackrel{\mathrm{def}}{=}}}}
\makeatletter
\newcommand*\SinT{\mathop{\operator@font SinT}\nolimits}
\newcommand*\CosT{\mathop{\operator@font CosT}\nolimits}
\makeatother

\begin{align*}
x_{O1} &= a_1\sqrt{(a_1^2-b_1^2)/(a_1^2-c_1^2)}\\
z_{O1} &= c_1\sqrt{(b_1^2-c_1^2)/(a_1^2-c_1^2)}\\
y_{O1} &= 0 \\
\CosT &= a_1\frac{\sqrt{(b_1^2-c_1^2)/(a_1^2-c_1^2)}}{b_1}\\
\SinT &= c_1\frac{\sqrt{(a_1^2-b_1^2)/(a_1^2-c_1^2)}}{b_1}\\
x_P &= 0.95x_{O1}\\
z_P &= x_Pz_{O1}/x_{O1}\\
n_X &\eqdef \SinT 0 \CosT\\
d_P &=  |x_P \SinT + z_P \CosT|\\
r_{Cyl} &=  b_1 \sqrt{1 -(b_1*d_P/a_1*c_1)^2}
\end{align*}

These equations can be loaded at the beginning of the code with 
the macro \Lcs{setEllipsoidVars}.



\section{Examples}
\subsection{An ellipsoid with a checkerboard pattern}

\begin{center}
\input{\jobname-exa02}
\end{center}

\inputCodeblockA[title=A first example (exa02)]{\jobname-exa02.tex}

\subsection{Ellipsoid skeleton}

This is a remarkable option developed by Jean-Paul Vignault. 
If the mesh is very fine (defined by the values of the \LKeyword{ngrid=n1 n2} 
option), the computation time will be very long! In this case, it is 
best to save the data for the resulting solid using the \Lkeyword{writesolid} option.

\begin{center}
\input{\jobname-exa03}
\end{center}

\inputCodeblockA[title=Using a data file (exa03)]{\jobname-exa03.tex}

An interesting variant allows you—using the \Lkeyword{affinegerm} option—to 
retain the central face and make it transparent so the interior 
is visible, or to assign the central faces a color different from 
that of the framework.

\begin{center}
\input{\jobname-exa04}
\end{center}

\inputCodeblockA[title=Option \Lkeyword{affinegerm} (exa04)]{\jobname-exa04.tex}


\subsection{Semi-ellipsoid}
\begin{center}
\input{\jobname-exa05}
\end{center}

\inputCodeblockA[title=A semi ellipsoid (exa05)]{\jobname-exa05.tex}


\subsection{Section by a horizontal plane}

\begin{center}
\input{\jobname-exa06}
\end{center}

\inputCodeblockA[title=Section by a horizontal plane (exa06)]{\jobname-exa06.tex}

\section{Slicing an ellipsoid into circular sections}
The solution to the problem posed in the 1870 competition for the Montpellier 
and Aix academies
%\footnote{Nouvelles annales de mathématiques 2e série, tome 10
%(1871), p. 17-26}:
(\url{http://www.numdam.org/item/NAM_1871_2_10_.pdf})
was written by \Index{Mace, Auguste@Auguste Macé}, a student of »Mathématiques spéciales« 
at the Grenoble lycée.~\cite{mace1871}
The problem statement consists of three parts; the first is phrased as follows:
»Given an ellipsoid, determine the points of contact of the tangent 
planes parallel to the planes of the circular sections;
construct two spheres, each tangent at two of these points (which are 
symmetric with respect to the major axis): find the equation of the
surfaces of revolution of the second degree circumscribed about these 
two spheres. Classification and discussion of these surfaces.«
It is understood that the first step of this part involves determining 
the umbilical points of the ellipsoid defined by the equation:

\[
\frac{x^2}{a^2}+\frac{y^2}{b^2}+\frac{z^2}{c^2}=1\quad\text{with } a>b>c
\]

\begin{center}
\input{\jobname-exa07}
\end{center}

\inputCodeblockA[title=Slicing into circular sections (exa07)]{\jobname-exa07.tex}

Auguste Macé’s demonstration begins with: »we know that the planes of 
the cyclic sections are parallel to the plane«:

\[
x=z\sqrt{\frac{\dfrac{1}{c^2}-\dfrac{1}{b^2}}{\dfrac{1}{b^2}-\dfrac{1}{a^2}}}
\]

Let us demonstrate that the equation of the circular section plane passing 
through the origin is indeed written in this form.

\begin{center}
\input{\jobname-exa08}
\end{center}

\inputCodeblockA[title=Circular sections (exa08)]{\jobname-exa08.tex}

The circular section passing through the origin is a circle with a 
radius equal to the semi-axis along the Oy axis: b. To simplify, 
let us consider the $xOz$ plane. The section of the ellipsoid in this 
plane is an ellipse with semi-major axis a and semi-minor axis c.

\begin{center}
\begin{pspicture}(-6,-4)(6,4)
\psgrid[subgriddiv=0,gridcolor=lightgray,griddots=10,gridlabels=0pt]
\psframe(-6,-4)(6,4)
\pstVerb{
% les demi-axes de l'ellipsoïde
/aa 4 def /bb 2.5 def /cc 1.8 def
/arccos {
   dup
   dup mul neg 1 add sqrt
   exch
   atan
} def
/ti bb dup mul cc dup mul sub
    aa dup mul cc dup mul sub
   div
   sqrt arccos def
/CosT bb dup mul cc dup mul sub aa dup mul cc dup mul sub div sqrt bb div aa mul def
/SinT aa dup mul bb dup mul sub aa dup mul cc dup mul sub div sqrt bb div cc mul def
/tO1 aa dup mul ti cos mul cc dup mul ti sin mul atan def
/xO1 aa aa dup mul bb dup mul sub aa dup mul cc dup mul sub div sqrt mul def
/yO1 cc bb dup mul cc dup mul sub aa dup mul cc dup mul sub div sqrt mul def
/equationTangente{
/yO exch def /xO exch def
/x1 xO 2 add def
/x2 xO 2 sub def
/y1 cc aa div dup mul neg xO yO div mul x1 mul yO cc aa div dup mul xO dup mul mul yO div add add def
/y2 cc aa div dup mul neg xO yO div mul x2 mul yO cc aa div dup mul xO dup mul mul yO div add add def
} def%
/equationNormale{
/yO exch def /xO exch def
/x1 xO 0.25 add def
/x2 xO 0.25 sub def
/y1 aa cc div dup mul yO xO div mul x1 mul yO aa cc div dup mul yO mul sub add def
/y2 aa cc div dup mul yO xO div mul x2 mul yO aa cc div dup mul yO mul sub add def
} def
/xC1 xO1 1 cc aa div dup mul sub mul def
/Radius xC1 xO1 sub dup mul yO1 dup mul add sqrt def
}%
\pnodes(!aa ti cos mul cc ti sin mul){P1}(!aa ti cos mul neg cc ti sin mul neg){P2}
\pnodes(!aa ti cos mul neg cc ti sin mul){P3}(!aa ti cos mul cc ti sin mul neg){P4}
% les ombilics (4)
\pnodes(!xO1 yO1){O1}(!xO1 neg yO1 neg){O4}
\pnodes(!xO1 yO1 neg){O2}(!xO1 neg yO1){O3}
\psdots[linecolor=red](O1)(O2)(O3)(O4)
%\psline[linecolor=red]{*-*}(O1)(O2)
%\psline[linecolor=red]{*-*}(O3)(O4)
\psline[linecolor=red](P1)(P2)
\psline[linecolor=red](P3)(P4)
\psdots(P1)(P2)(P3)(P4)
\pscircle[linestyle=dashed](0,0){!bb}
% les tangentes aux ombilics
% y=-(c/a)^2*xO/yO*x +a^2/xO
\psline[linecolor=blue](! xO1 yO1 equationTangente x1 y1)(! xO1 yO1 equationTangente x2 y2)
\psline[linecolor=blue](! xO1 neg yO1 equationTangente x1 y1)(! xO1 neg yO1 equationTangente x2 y2)
\psline[linecolor=blue](! xO1 yO1 equationTangente x1 y1)(! xO1 yO1 equationTangente x2 y2)
\psline[linecolor=blue](! xO1 neg yO1 neg equationTangente x1 y1)(! xO1 neg yO1 neg equationTangente x2 y2)
\psline[linecolor=blue](! xO1 yO1 neg equationTangente x1 y1)(! xO1 yO1 neg equationTangente x2 y2)
\psline[linecolor=red]{->}(!xO1 yO1)(! xO1 yO1 equationNormale x1 y1)% (! xO1 yO1 equationNormale x2 y2)
\psline[linecolor=red]{->}(!xO1 neg yO1)(! xO1 neg yO1 equationNormale x2 y2)% (! xO1 neg yO1 equationNormale x2 y2)
\psline[linecolor=red]{->}(! xO1 yO1 neg)(! xO1 yO1 neg equationNormale x1 y1)
\psline[linecolor=red]{->}(! xO1 neg yO1 neg)(! xO1 neg yO1 neg equationNormale x2 y2)
\psline(!aa neg 0)(! aa 0)
\psdot(!xC1 0)
\pscircle[linecolor=green](!xC1 0){!Radius}
\psdot(!xC1 neg 0)
\pscircle[linecolor=green](!xC1 neg 0){!Radius}
%\psline[linecolor=magenta](! 70 cos aa mul 70 sin cc mul equationTangente x1 y1)(! 70 cos aa mul 70 sin cc mul equationTangente x2 y2)
\psline{<->}(0,3)(0,0)(5,0)
\uput[u](0,3){$z$}
\uput[r](5,0){$x$}
\uput[d](0,0){$O$}
%\pcline[offset=8pt,linestyle=none](0,0)(P1)
%\ncput*[nrot=:U]{$b$}
\pcline[offset=8pt,linestyle=none](P3)(0,0)
\uput[u](P1){$A_1$}
\uput[u](P3){$A_2$}
\uput[d](P2){$A_3$}
\uput[d](P4){$A_4$}
\ncput*[nrot=:U]{$b$}
\psarc[linecolor=red]{->}(0,0){1}{0}{!180 CosT arccos sub}
\uput{1.11}[!180 CosT arccos sub 2 div](0,0){\red$\theta$}
\parametricplot[plotpoints=360,linewidth=2\pslinewidth]{0}{360}{aa t cos mul  cc t sin mul}
\uput[d](O1){$O_1$}
\uput[u](O2){$O_2$}
\uput[d](O3){$O_3$}
\uput[u](O4){$O_4$}
\end{pspicture}
\end{center}




The two circular sections passing through O are circles of radius b. 
Let us determine the coordinates of the points $Ai$.

Ellipse:
\[
\frac{x^2}{a^2}+\frac{z^2}{c^2}=1
\]

Circle of radius $b$ :

\[
\left\{
\begin{aligned}
x  &= b\cos\theta\\
z &= b\sin\theta
\end{aligned}
\right.
\]

The two circular sections passing through O are circles of radius b. Let us determine the coordinates of the points Ai.
Ellipse:

\[
\frac{b^2\cos^2\theta}{a^2}+\frac{b^2\sin^2\theta}{c^2}=1 \Rightarrow \frac{\cos^2\theta}{a^2}+\frac{\sin^2\theta}{c^2}=\frac{1}{b^2}
\]

We are looking for $\theta$.

\[
\frac{\cos^2\theta}{a^2}+\frac{1-\cos^2\theta}{c^2}=\frac{1}{b^2}\Rightarrow \cos^2\theta\left[\frac{1}{a^2}-\frac{1}{c^2}\right]=\frac{1}{b^2}-\frac{1}{c^2}
\]

We deduce from this::

\begin{align*}
\cos\theta &=\pm\sqrt{\dfrac{\dfrac{1}{c^2}-\dfrac{1}{b^2}}{\dfrac{1}{c^2}-\dfrac{1}{a^2}}} & 
\sin\theta&=\pm\sqrt{\dfrac{\dfrac{1}{b^2}-\dfrac{1}{a^2}}{\dfrac{1}{c^2}-\dfrac{1}{a^2}}} &
\tan\theta&=\pm\sqrt{\dfrac{\dfrac{1}{b^2}-\dfrac{1}{a^2}}{\dfrac{1}{c^2}-\dfrac{1}{b^2}}}
\end{align*}

The equations of the planes of circular section passing through O are:

\[
z=\pm\sqrt{\dfrac{\dfrac{1}{b^2}-\dfrac{1}{a^2}}{\dfrac{1}{c^2}-\dfrac{1}{b^2}}}x
\]

For the coordinates of the four umbilics, one should refer to Auguste Macé’s irrefutable 
proof. For O1:

\[
\left\{
\begin{aligned}
x_1 &= a\sqrt{\dfrac{a^2-b^2}{a^2-c^2}}\\
y_1 &=0\\
z_1 &= c\sqrt{\dfrac{b^2-c^2}{a^2-c^2}}
\end{aligned}
\right.
\]


Here, for example, are the \Index{tangent} plane and the normal to the ellipsoid at $O1$.

\begin{center}
\input{\jobname-exa09}
\end{center}

\inputCodeblockA[title=Tangent plane (exa09)]{\jobname-exa09.tex}

The unit normal vector to the cross-sectional planes is:

\[
\left\{
\begin{aligned}
n_x  &=\pm \dfrac{c}{b}\sqrt{\dfrac{a^2-b^2}{a^2-c^2}}\\
n_y&=0\\
n_z  &= \dfrac{a}{b}\sqrt{\dfrac{b^2-c^2}{a^2-c^2}}
\end{aligned}
\right.
\]


If we consider a point on one of the planes located on the ray which 
joins $O$ to a navel (for example O1(x1, 0, z1)), its
coordinates are:

\[
\left\{
\begin{aligned}
x_P  &=kx_1\\
y_P  &=0\\
z_P  &= \dfrac{x_Pz_1}{x_1}
\end{aligned}
\right.
\]

The distance from $O$ to the section plane is $d = |x_P n_x + z_p n_z|$, 
with $0<d<\dfrac{ac}{b}$, $\dfrac{ac}{b}$ is the distance from $O$ 
to the umbilical points.

The radius of the circular sections is:


\[
r=b\sqrt{1-\left(\frac{bd}{ac}\right)^2}
\]

A cylinder of the same radius can be fitted to a circular section of the ellipsoid.

\begin{center}
\input{\jobname-exa10}
\end{center}

\inputCodeblockA[title=Circular section (exa10)]{\jobname-exa10.tex}


Cutting of two circular sections:

\begin{center}
\input{\jobname-exa11}
\end{center}

\inputCodeblockA[title=Two sections (exa11),breakable]{\jobname-exa10.tex}

Cutting of three circular sections:

\begin{center}
\input{\jobname-exa12}
\end{center}

\inputCodeblockA[title=Cutting of three circular sections (exa12)]{\jobname-exa12.tex}

Cutting of four circular sections:

\begin{center}
\input{\jobname-exa13}
\end{center}

\inputCodeblockA[title=Cutting of four circular sections (exa13)]{\jobname-exa13.tex}


A slice with a circular cross-section (a disk) is cut:

\begin{center}
\input{\jobname-exa14}
\end{center}

\inputCodeblockA[title=A circular cross-section (exa14),breakable]{pst-ellipsoid-doc-exa14.tex}


Remove one washer and keep the two remaining parts.

% code PSTricks
% enlever une rondelle circulaire (tronc-conique)
\begin{center}
\input{\jobname-exa15}
\end{center}

\inputCodeblockA[title=Remaining two parts (exa15),breakable]{\jobname-exa15}

\nocite{*}
\printbibliography

\printindex
\end{document} 

