# Creating an ellipsoidal 3D surface

I am trying to find the equation of a 3D ellipsoidal surface. I have thought of two approaches which are schematically shown below:

By revolving an elliptical arc over a 3D elliptical path:

Or by scaling an elliptical arc while translating in $z$-direction:

I thought the first approach (revolving) is easier. Here is my description of what I have done. The elliptical arc segment, which lies in $xy$-plane, that revolves around $y$-axis on an elliptical path (non-circular) to create a 3D ellipsoidal surface.

The revolving elliptical segment has the following equation ($0<\theta\le\pi/2$):

$$\frac{x^2}{R_x^2}+\frac{y^2}{R_y^2} = 1,\mathrm{\ \ \ or\ \ \ } \begin{cases} x = R_x\cos\left(\theta\right)\\ y = R_y\sin\left(\theta\right) \end{cases}$$

The revolving angle is called $\phi$ and revolves $0<\phi\le\pi/2$ in the $xz$-plane according to the following elliptical path:

$$\frac{x^2}{{R^\prime}_x^2}+\frac{z^2}{R_z^2} = 1, \mathrm{\ \ \ or\ \ \ } \begin{cases} x = {R^\prime}_x\cos\left(\phi\right)\\ z = R_z\sin\left(\phi\right) \end{cases}$$

While revolving I want to scale down $R_y$ according to $\phi$:

$$R_y = h\cos\left(\phi\right)$$

where $h$ is a constant. So, as the elliptical arc revolves by $\phi$, $R_y$ decreases and so as $R_x$.

In the $\phi$-plane, the points on the revolved ellipse has the following equations:

$$\begin{cases} x = {\left(\left[{{R^\prime}_x}\cos\left(\phi\right)\right]^2+\left[R_z\sin\left(\phi\right)\right]^2\right)}^\frac12\cos\left(\theta\right)\\ y = h\cos\left(\phi\right)\sin\left(\theta\right)\\ z = R_z\sin\left(\phi\right) \end{cases}$$

When I plot the above parametric equations in MATLAB I don't get the expected surface. Could someone kindly help me?

% Here is the MATLAB code I used.
Rx = 1;
Rz = 1;
h  = 2;

n = 100;
[theta, phi] = meshgrid(linspace(0,pi/2,n), linspace(0,pi/2,n));

x = (Rx^2*cos(phi).^2+Rz^2*sin(phi).^2).^0.5.*cos(theta);
y = h*cos(phi).*sin(theta);
z = Rz*sin(phi);

surf(x,y,z), shading interp, axis equal, xlabel('x'), ylabel('y'), zlabel('z')


Here is the MATLAB result:

• I don't get it. What is it you are trying to do? Do you want to plot something, or is plotting just a means of checking if your equations are correct? – knedlsepp Dec 19 '14 at 20:56
• I tried to better clarify my question in this post: math.stackexchange.com/q/1072458/62050 – AFP Dec 19 '14 at 21:01
• So this is a duplicate? Are you looking for this: en.wikipedia.org/wiki/Ellipsoid#Parameterization ? – knedlsepp Dec 19 '14 at 21:04
• This is not a duplicate and the Wikipedia information is not what I want. In the link I provided, I approached differently. – AFP Dec 19 '14 at 21:07
• Ok I guess by elliptical you don't necessarily mean a linear transformation of a circle? Am I correct to say, that what you want is an equation for the surface you drew: a straight line in the z-direction, a circle in the x-direction, and something that looks a lot like an ellipsoid in between? – knedlsepp Dec 19 '14 at 21:24

The following should fulfill your requirements. It is the subsurface of an elliptical $z$-axis cylinder $(x/R_x)^2 + (y/R_y)^2 = 1$, that is contained within the filled elliptical $y$-axis cylinder $(x/R_x)^2 + (z/R_z)^2 < 1$.

$$M:=\{(x,y,z) \in \mathbb{R}^3 : (x/R_x)^2 + (y/R_y)^2 = 1; (x/R_x)^2 + (z/R_z)^2 < 1 \textrm{ and } x>0, z>0\}$$

Rx = 3;
Ry = 2;
Rz = 6;

n = 100;
x = linspace(0,Rx,n);
z = linspace(0,Rz,n);
[U, V] = ndgrid(x, z);

X = U.*sqrt((1-(V/Rz).^2));
Y = sqrt((1-(X/Rx).^2)*Ry^2);
Z = V;
surf(Z,X,Y); % The ordering is just swapped so we can rotate it more easily!
xlabel('z'), ylabel('x'), zlabel('y');