%%
%% Polar Graphs
% A few examples of polar graphs from E & P for students af Calculus ED2

% First examples: Circles - first define the angular parameter $t$
    t=0:0.01:2*pi;
% Ie, $t$ runs from zero to $2\pi$. Note that the command makes Matlab
% calculate a table called t of 629 numbers from 
% 0 to 2*pi with increments of 0.01. Now calculate the radial parameter
% from the table t
    r1=2*sin(t);
% Matlab creates a table of 629 entries which are sine evaluated at each of
% the entries. Now plot the polar graph
    t=0:0.01:2*pi;
    r1=2*sin(t);
    polar(t,r1);figure(gcf);
%% Further examples: Cardiodid or not - and roses
% 
% This plots a cardiodid, recycling the parameter t from above
r2=2+2*sin(t);%cardiodid
polar(t,r2);figure(gcf);
%%
r3=2-2*sin(t);%another cardiodid
polar(t,r3);figure(gcf);
%%
r4=2-2*cos(t);%yet another cardiodid
polar(t,r4);figure(gcf);
%% 
% Is this just yet another cardiodid
r5=1+2*cos(t);%yet another cardiodid?
polar(t,r5);figure(gcf);
% NO!
%%
r6=1+cos(t);%but this is yet another cardiodid?
polar(t,r6);figure(gcf);
%%
r7=1-cos(t);%and so is this
polar(t,r7);figure(gcf);
%% Make your own examples
%%
%% Roses with prescribed Number of Leaves
% Changing parameters in the equations
r8=cos(2*t);% A four-leaved rose.
polar(t,r8);figure(gcf);
%%
r9=cos(4*t);% An 8-leaved rose.
polar(t,r9);figure(gcf);
%%
r10=cos(3*t);% A three-leaved rose.
polar(t,r10);figure(gcf);
%%
%%
r11=0.5*sin(5*t);% A 5-leaved rose.
polar(t,r11);figure(gcf);
%%
r12=1+5*sin(5*t);% A 10-leaved rose.
polar(t,r12);figure(gcf);
%% A Butterfly
% This needs an adjustment of the parameter
t1=0:0.01:8*pi;
r13=exp(cos(t1))-2*cos(4.*t1)+sin(1/4.*t1).^3;
polar(t1,r13);figure(gcf);

%% A Maple Leaf?
% 
t2=-pi/2:0.001:3*pi/2;
s=100./(100+(t2-pi/2).^8); % What is s? Plot it - its a bump that becomes small outside [0;pi]
figure;plot(t2,s);
%%
r14=(2-sin(7.*t2)-cos(30.*t2)/2); % What is r14? Plot it - it varies in an irregular fashion! 
polar(t2,r14);figure(gcf); 
%% Multiply s with r14 to get a maple leaf in the upper half plane
polar(t2,r14.*s);figure(gcf);
%%
