ellipsoid

Generates the coordinates of an ellipsoid.

Category: Graphics > 2-D and 3-D Plots

Syntax

[X, Y, Z] = ellipsoid(xc, yc, zc, xr, yr, zr)

An ellipsoid centered at (xc, yc, zc) with semi-axes xr, yr, zr, using 20 faces.

[X, Y, Z] = ellipsoid(___, n)

Uses n faces, returning (n+1)-by-(n+1) matrices.

ellipsoid(___)

With no outputs, draws the surface.

Description

The surface satisfies ((x-xc)/xr)^2 + ((y-yc)/yr)^2 + ((z-zc)/zr)^2 = 1. Equal semi-axes give a sphere. Increase n for a smoother picture.

Input arguments

xc, yc, zc
Coordinates of the center.
xr, yr, zr
Semi-axis lengths along x, y and z.
n
Number of faces, 20 by default.

Output arguments

X, Y, Z
Matrices of surface coordinates, to pass to surf or mesh.

Example

Check the equation

[X, Y, Z] = ellipsoid(1, 0, 0, 2, 1, 3, 10);
disp(size(X))
r = ((X-1)/2).^2 + Y.^2 + (Z/3).^2;
disp(max(abs(r(:) - 1)) < 1e-12)
surf(X, Y, Z)
axis equal
Output
    11    11
   1

See also

sphere cylinder surf mesh