(* Ellipse in polar coordinates *)

(* semidiameter 1 (degrees) *)
(* a=5; *)
(* semidiameter 2 (degrees) *)
(* b=5; *)

(* radius of ellipse center in polar coord frame (degrees) *)
(* rcenter=0; *)
(* angle of ellipse center in polar coord frame (degrees) *)
(* θcenter=315; *)
(* angle of ellipse rotation in polar coord frame (degrees) *)
(* φcenter=0; *)

(* Polar equation of ellipse, general case, in cosine space *)
(* ref email PDFs to Jove and SARA lists in same folder as this script *)
P[θ_,a_,b_,rcenter_,θcenter_,φcenter_]:=Sin[rcenter*π/180]*90*((b^2-a^2)*Cos[θ+θcenter-2*φcenter]+(a^2+b^2)*Cos[θ-θcenter]);
R[θ_,a_,b_,φcenter_]:=(b^2-a^2)*Cos[2*θ-2*φcenter]+a^2+b^2;
Q[θ_,a_,b_,rcenter_,θcenter_,φcenter_]:=(Sqrt[2])*a*b*(Sqrt[R[θ,a,b,φcenter]-2*(Sin[rcenter*π/180]*90)^2*Sin[θ-θcenter]^2]);
r[θ_,a_,b_,rcenter_,θcenter_,φcenter_]:=(P[θ,a,b,rcenter,θcenter,φcenter]+Q[θ,a,b,rcenter,θcenter,φcenter])/R[θ,a,b,φcenter];

(* convert cosine space to linear polar space *)
rp[θ_,a_,b_,rcenter_,θcenter_,φcenter_]:=ArcSin[r[θ,a,b,rcenter,θcenter,φcenter]/90]*180/π;

(* convert linear polar to cosine space *)
(* rcenter=Sin[rcenter*π/180]*90; *)
(* a=Sin[a*π/180]*90; *)
(* b=Sin[b*π/180]*90; *)

(* convert degrees to radians *)
(* θcenter=θcenter*π/180; *)
(* φcenter=φcenter*π/180; *)

rings=Table[Sin[i*π/180]*90,{i,15,90,15}];
ringsp=Table[i,{i,15,90,15}];
ringsp2={5,10,20,25,35,40,50,55,65,70,80,85};

(*
(* plot the circular ellipse in cosine space (an /orthographic/ 2D projection of the sky) *)
a=7.5;
b=7.5;
a=Sin[a*π/180]*90;
b=Sin[b*π/180]*90;
Show[
PolarPlot[{
Table[r[t,a,b,0,i,0],{i,{0,π/2,7 π/4}}],
Table[r[t,a,b,15,i,0],{i,{0,π/2,7 π/4}}],
Table[r[t,a,b,30,i,0],{i,{0,π/2,7 π/4}}],
Table[r[t,a,b,45,i,0],{i,{0,π/2,7 π/4}}],
Table[r[t,a,b,60,i,0],{i,{0,π/2,7 π/4}}],
rings},{t,0,2 π},
PlotRange->{{-90,90},{-90,90}},
Frame->False,
Axes->True,
Ticks->None,
Frame->True,
PlotStyle->{Blue,Darker[Green],Magenta,Orange,Red,Gray},
PlotPoints->10000
],
Graphics[{Gray,Rotate[Line[90 {{-1,0},{1,0}}],Pi/3]}],
Graphics[{Gray,Rotate[Line[90 {{-1,0},{1,0}}],Pi/6]}],
Graphics[{Gray,Rotate[Line[90 {{-1,0},{1,0}}],2 Pi/3]}],
Graphics[{Gray,Rotate[Line[90 {{-1,0},{1,0}}],5 Pi/6]}]
]

(* plot the circular ellipse in linear polar space (an AZ/EL sky map) *)
a=7.5;
b=7.5;
a=Sin[a*π/180]*90;
b=Sin[b*π/180]*90;
PolarPlot[{
Table[rp[t,a,b,0,i,0],{i,{0,π/2,7 π/4}}],
Table[rp[t,a,b,15,i,0],{i,{0,π/2,7 π/4}}],
Table[rp[t,a,b,30,i,0],{i,{0,π/2,7 π/4}}],
Table[rp[t,a,b,45,i,0],{i,{0,π/2,7 π/4}}],
Table[rp[t,a,b,60,i,0],{i,{0,π/2,7 π/4}}],
ringsp},{t,0,2 π},
PlotRange->{{-90,90},{-90,90}},
Frame->False,
Axes->True,
Ticks->None,
Frame->True,
PlotStyle->{Blue,Darker[Green],Magenta,Orange,Red,Gray},
PlotPoints->10000
]

(* plot the TFD array 20 MHz ellipse in cosine space (an /orthographic/ 2D projection of the sky) *)
a=35/2;
b=15/2;
a=Sin[a*π/180]*90;
b=Sin[b*π/180]*90;
PolarPlot[{
Table[r[t,a,b,0,i,0],{i,{0,π/2,7 π/4}}],
Table[r[t,a,b,15,i,0],{i,{0,π/2,7 π/4}}],
Table[r[t,a,b,30,i,0],{i,{0,π/2,7 π/4}}],
Table[r[t,a,b,45,i,0],{i,{0,π/2,7 π/4}}],
Table[r[t,a,b,60,i,0],{i,{0,π/2,7 π/4}}],
rings},{t,0,2 π},
PlotRange->{{-90,90},{-90,90}},
Frame->False,
Axes->True,
Ticks->None,
Frame->True,
PlotStyle->{Blue,Darker[Green],Magenta,Orange,Red,Gray},
PlotPoints->10000
]

(* plot the TFD array 20 MHz ellipse in linear polar space (an AZ/EL sky map) *)
a=35/2;
b=15/2;
a=Sin[a*π/180]*90;
b=Sin[b*π/180]*90;
Show[
PolarPlot[{
Table[rp[t,a,b,0,i,0],{i,{0,π/2,7 π/4}}],
Table[rp[t,a,b,15,i,0],{i,{0,π/2,7 π/4}}],
Table[rp[t,a,b,30,i,0],{i,{0,π/2,7 π/4}}],
Table[rp[t,a,b,45,i,0],{i,{0,π/2,7 π/4}}],
Table[rp[t,a,b,60,i,0],{i,{0,π/2,7 π/4}}],
ringsp2},{t,0,2 π},
PlotRange->{{-90,90},{-90,90}},
Frame->False,
Axes->True,
Ticks->None,
Frame->True,
PlotStyle->{Blue,Darker[Green],Magenta,Orange,Red,Gray},
PlotPoints->10000
],
Graphics[{Gray,Rotate[Line[90 {{-1,0},{1,0}}],Pi/3]}],
Graphics[{Gray,Rotate[Line[90 {{-1,0},{1,0}}],Pi/6]}],
Graphics[{Gray,Rotate[Line[90 {{-1,0},{1,0}}],2 Pi/3]}],
Graphics[{Gray,Rotate[Line[90 {{-1,0},{1,0}}],5 Pi/6]}]
]
*)

(* plot the TFD array 20 MHz ellipse in linear polar space (an AZ/EL sky map) *)
a=35; (* EW HPBW in degrees *)
b=15; (* NS HPBW in degrees *)
AZ=180; (* Azimuth in degrees *)
EL = 45; (* Elevation in degrees *)
a=Sin[a/2*π/180]*90;
b=Sin[b/2*π/180]*90;
AZ=AZ*π/180+π/2;
EL=90-EL;
Show[
PolarPlot[{
rp[t,a,b,EL,AZ,0],
ringsp,
ringsp2},{t,0,2 π},
PlotRange->{{-90,90},{-90,90}},
Frame->False,
Axes->True,
Ticks->None,
Frame->True,
PlotStyle->{{Thick,Green},{Thick,Gray},{Lighter[Gray],Thin}},
PlotPoints->10000
],
Graphics[{Thick,Gray,Rotate[Line[90 {{-1,0},{1,0}}],Pi/3]}],
Graphics[{Thick,Gray,Rotate[Line[90 {{-1,0},{1,0}}],Pi/6]}],
Graphics[{Thick,Gray,Rotate[Line[90 {{-1,0},{1,0}}],2 Pi/3]}],
Graphics[{Thick,Gray,Rotate[Line[90 {{-1,0},{1,0}}],5 Pi/6]}]
]
PolarPlot[
{rp[t,a,b,EL,AZ,0],90},{t,0,2 π},
PlotRange->{{-90,90},{-90,90}},
Frame->False,
Axes->False,
Ticks->None,
Frame->True,
PlotStyle->{Directive[Thick,Green],Directive[Thin,Gray]},
PlotPoints->10000
]

a//N
b//N
EL//N
AZ//N
Q[4.8,a,b,EL,AZ,0]//N
rp[4.8,a,b,EL,AZ,0]//N

Column[Table[{t, Q[t,a,b,EL,AZ,0], rp[t,a,b,EL,AZ,0]},{t,0,2 π,0.05}]]

PNG SIZE GUIDE AS FOLLOWS

rings//N

r[1,20,20,0,0,0]//N

R[1,20,20,0]//N

Q[1,20,20,0,0]//N