function DrawEllipse(a,b,phi)
% Displays the ellipse (x/a)^2 + (y/b)^2 +1 and also
% what it looks like after it is rotated phi radians counterclockwise.

close all
% Plot the ellipse...
n = 200;
theta = linspace(0,2*pi,n);
x = a*cos(theta);
y = b*sin(theta);
plot(x,y)
axis equal
hold on

% Generate points on the tilted ellipse...
for k=1:n
[x(k),y(k)] = Rotate(x(k),y(k),phi);
end
plot(x,y,'r')
hold off

function [xnew,ynew] = Rotate(x,y,phi)
% Rotates the point (x,y) about the origin phi radians
c = cos(phi);
s = sin(phi);
xnew = c*x - s*y;
ynew = s*x + c*y;