function [ x, y ] = ellipse_xy( a, e ) % ELLIPSE_XY Generate the x, y coordinates of an ellipse with specified % semi-major axis a and eccentricity e % The units of x and y are determined by a % The coordinate system is such that the center of the ellipse is at % (0,0), with the semi-major axis along a. b = a * sqrt(1-e^2); theta = 0 : 0.01 : 2 *pi; r = a * (1-e^2)./(1+e.*cos(theta)); x = r .* cos(theta); y = r .* sin(theta); % This has the origin at one focus. Shift the origin to the center of the % ellipse x = x + a*e; end