Boost logo

Boost :

From: Andy Little (andy_at_[hidden])
Date: 2003-12-13 08:40:03

"Paul A. Bristow" <boost_at_[hidden]> wrote in message


> Seriously for a moment, one of group who don't use SI (and reluctantly I
> admit they can't) are astronomers. A demo using light years (or parsecs?)
> also be useful.

//using pqs-100-01 ( a great improvement in speed and accuracy over

#include "../pqs.hpp"
using namespace physical_quantities;
double pi(){return 3.141593;}
int main()
    p_quantity< //pqs-1-00-01 style
>const G(6.7); //gravitational constant 6.7 kg-1.m3.s-2 e-11

    q_length::km const planet_radius(6400); //roughly !
    q_density::kg_div_m3 const planet_density(5464); // roughly!
    q_mass::kg planet_mass = (4.0/3)
    * pi() * power<3>(planet_radius)
    * planet_density;
    std::cout <<"mass of planet is roughly " << planet_mass <<'\n';

    //an object
    q_mass::kg object_mass(1);

    // ...on the planet surface
    q_force::N exerted_force_at_surface
    = (object_mass * planet_mass * G)
    std::cout << "force on object at surface is roughly "
    << exerted_force_at_surface <<'\n';

    // ...and a long way away
    q_length::pc object_distance(64e13/3.085678); // pc = 3.085678e16 m
    std::cout <<"force on object at " << object_distance <<" is roughly "
    << q_force::yN((object_mass * planet_mass *
G)/power<2>(object_distance)) <<'\n';
mass of planet is roughly 5.99983e+024 kg
force on object at surface is roughly 9.81418 N
force on object at 2.0741e+014 [m * 3.08568e+016] is roughly 9.81418e-024 yN

Andy Little

Boost list run by bdawes at, gregod at, cpdaniel at, john at