Drawing (Fresnel) ellipse and major axis

1k Views Asked by At

I am trying to draw the Fresnel ellipse and a line between two points (x1,y1) and (x2,y2). In addition I am trying to rotate the ellipse using atan2. First, I cannot understand why the drawn red axis is not same with ellipse's imaginative major axis. They have both different angle and length. Secondly, I am not sure if I am using the correct formulas for drawing a ellipse with rotation.

f=217.25;
Ht=45;
Hr=2.5;

figure (10);
x1=0;
x2=2.415512976422468e+04;
y1=2.609242854399548e+02+Ht;% Ht is trasmitter antenna height
y2=40.819199999995895+Hr;% Hr is receiver antenna height

% plot line of sight (major axis of ellipse)
hold on,plot([x1 x2],[y1 y2],'r')

% Plot 1st Fresnel zone - ELLIPSE
fr=f*1e6;% f in Hz
c=2.997925e8;% speed of light in m/s
lambda=c/fr; % wavelength in meters
a = 1/2*sqrt((x2-x1)^2+(y2-y1)^2); %majoraxis/2
r = sqrt(lambda*a/2);% b=r %secondaxis/2

t = linspace(0,2*pi,300);
X = a*cos(t);
Y = r*sin(t); 
w = atan2(y2-y1,x2-x1); %angle of two points
x = (x1+x2)/2 + X*cos(w) - Y*sin(w);
y = (y1+y2)/2 + X*sin(w) + Y*cos(w);
hold on, plot(x,y,'-k')
grid on

Fresnel ellipse

2

There are 2 best solutions below

0
On

I don't see any problem in making ellipse with rotation in your code. I was surprised the red line does not seem to match the major axis.

If you plotted the ellipse without rotation along with its major axis, and then rotated, it looks exactly the same as your picture.

X = a*cos(t);
X = [X -a];
Y = r*sin(t); 
Y = [Y 0];
x = xmid + X*cos(w) - Y*sin(w);
y = ymid + X*sin(w) + Y*cos(w);

So I think it may be due to Jaggies or other artifact due to smoothing in Matlab graphing. I cannot understand, either. I understand my answer may not be the best one but you get confirmation from my end regarding this interesting phenomena. I ran in Matlab 2017a.

BTW, the only concern I found in your code is not about the ellipse drawing. I believe in this line

r = sqrt(lambda*a/2);% b=r %secondaxis/2

should be

r = sqrt(lambda*a)/2;% b=r %secondaxis/2
0
On

I agree with @Y. Chang, I think the code is correct modulo the change in r, and for the sake of completeness, note that this problem disappears if you call

axis equal

so I guess it has to do with matlab plotting, but I don't understand why. Thanks for spotting out this issue though!