HSGlib.orbital Wiki
A gnuplot library to plot keplerian orbits and more
Status: Beta
Brought to you by:
hsgaspar
The gnuplot's parametric mode is a suitable way of plotting orbits, for instance:
load 'lib_orbital.plt'
set parametric
set trange [0:2*pi]
plot x_pq( 1.0, 0.5, 0.0, t ), y_pq( 1.0, 0.5, 0.0, t)
But, let's suppose that one wants to plot a quarter of the arc over the dashed orbit. In this case, the range are not the same for both the plots:
load 'lib_orbital.plt'
set parametric
set trange [0:1]
plot x_pq( 1.0, 0.5, 0.0, 2*pi*t ), y_pq( 1.0, 0.5, 0.0, 2*pi*t) w l dt '-',\
x_pq( 1.0, 0.5, 0.0, hpi*t ), y_pq( 1.0, 0.5, 0.0, hpi*t) w l lw 3
or to get properly a quarter arc of the orbit, one may appeal to the Eccentric anomaly
load 'lib_orbital.plt'
set parametric
set trange [0:1]
e = 0.5
plot x_pq( 1.0, e, 0.0, 2*pi*t ), y_pq( 1.0, e, 0.0, 2*pi*t) w l dt '-',\
x_pq( 1.0, e, 0.0, E2f(e,hpi*t) ), y_pq( 1.0, e, 0.0, E2f(e,hpi*t) ) w l lw 3
Suppose now, one wants to plot an arc from f0 = 1.234 rad up to f1 = 4.123rad. A possible solution would be:
x_pq( 1.0, e, 0.0, 1.234 + t*2.889 )...
In this case, the linear interpolation lin( a , b , u ) makes it easier:
load 'lib_orbital.plt'
set parametric
set trange [0:1]
e = 0.5
f0 = 1.234
f1 = 4.123
plot x_pq( 1.0, e, 0.0, 2*pi*t ), y_pq( 1.0, e, 0.0, 2*pi*t) w l dt '-',\
x_pq( 1.0, e, 0.0, lin(f0 , f1 , t) ), y_pq( 1.0, e, 0.0, lin(f0 , f1 , t) ) w l lw 3
Finally, an example of how plotting an arc respective to t0 = T/10 up to t1 = 3*T/4:
load 'lib_orbital.plt'
set parametric
set trange [0:1]
e = 0.5
n = 2*pi; #leads to T=1
t0 = 0.10
t1 = 0.75
plot x_pq( 1.0, e, 0.0, 2*pi*t ), y_pq( 1.0, e, 0.0, 2*pi*t) w l dt '-',\
x_pq( 1.0, e, 0.0, t2f(n , e , lin(t0 , t1 , t)) ), y_pq( 1.0, e, 0.0, t2f(n , e , lin(t0 , t1 , t)) ) w l lw 3