classdef E2 < E1
    % An E2 object represents the ellipse 
    %                (h+a*cos(t),kb*sin(t))        0<=t<=2pi  
    % rotated about its center.
   
    properties (Access = private)
        phi     % The counterclockwise rotation angle (degrees)
    end
    
    methods
        function E = E2(a,b,h,k,phi)
        % Constructs an E2 object
           E@E1(a,b,h,k)
           E.phi = phi;
           c = cos(phi*pi/180); s = sin(phi*pi/180);
           d = sqrt(a^2-b^2);
           E.F1.x =  h + c*d;
           E.F1.y =  k + s*d;
           E.F2.x =  h - c*d;
           E.F2.y =  k - s*d;
        end
       
        % Displays the ellipse referenced by ThisE2 in the current figure window
        % with color c. The two focii are also displayed. Assumes hold is on
        function Show(ThisE2,c)
        
           x = ThisE2.a*cos(linspace(0,2*pi));
           y = ThisE2.b*sin(linspace(0,2*pi));
           F1 = ThisE2.F1;
           F2 = ThisE2.F2;
           h = ThisE2.h;
           k = ThisE2.k;
           c2 = cos(ThisE2.phi*pi/180);
           s2 = sin(ThisE2.phi*pi/180);
           plot(h+c2*x-s2*y,k+s2*x+c2*y,c)
           plot(F1.x,F1.y,'.k','Markersize',20)
           plot(F2.x,F2.y,'.k','Markersize',20)
        end
                
    end
    
end

