Re: ellipse unclosed



Hi Grokwik,

grokwik wrote:
One way to draw an ellipse in gnuplot is to draw the two equations
(f(x),-f(x))
That's what I did in the following script :

set grid
set size ratio -1
set nokey
set xrange[-15:15]
set yrange[-15:15]
plot 0.5*(x+(4-3*x**2)**(0.5))
replot 0.5*(x-(4-3*x**2)**(0.5))

I think the 'set parametric' or 'set polar' might be the options you need. If a,b are semi-major/minor axes, and e is the eccentricity, and phi is a rotation angle (30 deg counterclockwise in the example):

This gives a rotated ellipse centred on the origin

set polar
a=4
b=2
e=sqrt(a**2-b**2)/a
phi=30*pi/180
plot sqrt( (a**2 * b**2)/(a**2*sin(t-phi)**2 + b**2*cos(t-phi)**2) )


This gives an ellipse centred on it's focus:

plot a*(1.0 - e**2)/(1.0-e*cos(t-phi))



OR... a quick and dirty way using 'parametric':

reset
set parametric
p=4
plot p*cos(t),sin(t)


hope that helps,
steve
.