This may border a bit on being spam, but I was emailed about an earlier
post on plotting ellipses in parametric mode with gnuplot. The topic
may be of interest to someone, so I thought I'd post it.
regards,
steve
> Is ist possible to rotate an ellipse in gnuplot in the parametric mode?
> plot p*cos(t-phi),sin(t-phi)
> is not working.
Yes, indeed it is. Shifting the parameter t by an angle phi for both
the x and y coordinates won't do the trick though. This method will
change the starting point of the parameter t by an amount phi. To see
that, include this line prior to the plot statement:
set trange [0:pi]
And then change the value of phi ... you should see a different
half-segment of the same (unrotated ellipse).
In parametric mode, you'll need to rotate the x,y vector using a
rotation matrix. So, if you have the vector:
[v] = [ a*cos(t), b*sin(t) ]
and the 2x2 rotation matrix:
[R] = [ cos(phi) sin(phi)
-sin(phi) cos(phi) ]
The vector product is:
[v_r] = [R][v] =
[ a*cos(phi)*cos(t) + b*sin(phi)*sin(t)
-a*sin(phi)*cos(t) + b*cos(phi)*sin(t) ]
So, to plot a rotated and translated ellipse in parametric mode, just
add on the translation coordinates for the centre of the ellipse [x0,
y0]. Here's a minimal script:
reset
set size ratio 1
set parametric
a=4.0
b=2.0
x0=1.0
y0=0.5
phi=30.0*pi/180.0
fx(t) = a*cos(phi)*cos(t)+b*sin(phi)*sin(t) + x0
fy(t) = -a*sin(phi)*cos(t)+b*cos(phi)*sin(t) + y0
set xrange [-10:10]
set yrange [-10:10]
plot fx(t),fy(t) with line
Hope that helps!
regards,
steve