Sha256: 54c5d9aca7c08bdd6915435cf2b6edad5982ac7467b20147e81b93f83391962a

Contents?: true

Size: 1.01 KB

Versions: 6

Compression:

Stored size: 1.01 KB

Contents

#!/usr/bin/env ruby
require("gsl")

include GSL::CONST::MKSA
puts("In MKSA unit")

c  = SPEED_OF_LIGHT;
au = ASTRONOMICAL_UNIT;
minutes = MINUTE;

# distance stored in meters
r_earth = 1.00 * au;
r_mars  = 1.52 * au;

t_min = (r_mars - r_earth) / c;
t_max = (r_mars + r_earth) / c;

printf("light travel time from Earth to Mars:\n");
printf("c = %e [m/s]\n", c)
printf("AU = %e [m]\n", au)
printf("minutes = %e [s]\n", minutes)
printf("minimum = %.1f minutes\n", t_min / minutes);
printf("maximum = %.1f minutes\n\n", t_max / minutes);


include GSL::CONST::CGSM
puts("In CGSM unit")

c  = SPEED_OF_LIGHT;
au = ASTRONOMICAL_UNIT;
minutes = MINUTE;

# distance stored in meters
r_earth = 1.00 * au;
r_mars  = 1.52 * au;

t_min = (r_mars - r_earth) / c;
t_max = (r_mars + r_earth) / c;

printf("light travel time from Earth to Mars:\n");
printf("c = %e [cm/s]\n", c)
printf("AU = %e [cm]\n", au)
printf("minutes = %e [s]\n", minutes)
printf("minimum = %.1f minutes\n", t_min / minutes);
printf("maximum = %.1f minutes\n", t_max / minutes);

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
gsl-2.1.0.3 examples/const/travel.rb
gsl-2.1.0.2 examples/const/travel.rb
gsl-2.1.0.1 examples/const/travel.rb
gsl-2.1.0 examples/const/travel.rb
gsl-1.16.0.6 examples/const/travel.rb
rb-gsl-1.16.0.5 examples/const/travel.rb