I'm trying to calculate the equation of an ellipsoidal capsule. It is a problem similar to what was presented here but with a twist: this time the capsule is made of two ellipsoid of axes length a, b and c at each end (see below for a sketch). Given that the capsule is centered at $(0,0,0)$ and with a cylinder of length 2h, such as the center of the is at $(0,0,\pm h)$, I have the following system: $$ \frac{x^2}{a^2}+\frac{y^2}{b^2}+\frac{(z-h)^2}{c^2}=1 $$ for $z\geqq h$ and similarly: $$ \frac{x^2}{a^2}+\frac{y^2}{b^2}+\frac{(z+h)^2}{c^2}=1 $$ for $z\leqq -h$.
Finally the equation for the elliptic cylinder: $$ \frac{x^2}{a^2}+\frac{y^2}{b^2}=1 $$ for $-h\geqq z\leqq h$.
I believe there should be a way to define a continuous function $F(x,y,z)$ that encapsulate (forgive the pun) this system, but I must be making a mistake in my calculations because I can never reach a clean formula at the end that I could easily use to define the boundaries in my simulation. Can anyone help me on that matter? Even a lead would be welcomed.

All three parts of your surface are of the form $$ \frac{x^2}{a^2} + \frac{y^2}{b^2} + \frac{f(z)^2}{c^2} = 1, $$ where $$ f(z) = \begin{cases} z+h, & z \leq -h, \\ 0, & -h \leq z \leq h, \\ z-h, & h \leq z. \end{cases} $$
Here's a graph of $f$ with $h=1$.
Any piecewise linear function can be assembled out of absolute value functions if you like. After a bit of monkeying around, you might find $$ f(z) = \frac{|z+h| + |z-h| - 2h}{2}. $$ Or if you prefer to use a maximum, $$ f(z) = \max\{0, |z|-h\}. $$
Keep in mind that either of these expressions is just syntactic sugar for the piecewise definition, as any implementation of them requires analyzing cases for evaluation anyway. Hence, it is just reverting back to the piecewise definition, but out of sight. One advantage from an analytic perspective is that since we know that applying absolute value or maximum is continuous, these expressions for $f$ immediately demonstrate that it is continuous, as desired.
Here's an image of the capsule with $(a, b, c, h) = (2, 4, 3, 2)$, and you can mess around with the parameters here.