コード例 #1
0
ファイル: test_grav_prism.c プロジェクト: luman75/tesseroids
static char * test_prism2sphere_gzz()
{
    SPHERE sphere;
    PRISM prism = {3000,-5000,5000,-5000,5000,-5000,5000,0,0,0};
    double dist, resprism, ressphere;

    /* Make a sphere with the same mass as the prism and put it at the origin */
    prism2sphere(prism, 0, 0, 0, &sphere);

    for(dist=60000; dist <= 500000; dist += 500)
    {
        resprism = prism_gzz(prism,0,0,-dist);
        ressphere = sphere_gzz(sphere,0,90,dist);

        sprintf(msg, "(distance %g m) prism = %.5f  sphere = %.5f", dist,
                resprism, ressphere);
        mu_assert_almost_equals(resprism, ressphere, 0.001, msg);
    }

    return 0;
}
コード例 #2
0
static char * test_prism2sphere()
{
    double expect, res;
    SPHERE sphere;
    int i;
    PRISM prisms[4] = {
        {1,0,1000,0,2000,100,2000,0,0,0},
        {1,-500,200,300,500,-1000,4000,0,0,0},
        {1,-10000000,5000000,5000000,8000000,0,3000000,0,0,0},
        {1,-1000000,50000,500000,800000,0,300000,0,0,0}};

    for(i = 0; i <  4; i++)
    {
        prism2sphere(prisms[i], 0., 0., 0., &sphere);
        res = sphere_volume(sphere);
        expect = prism_volume(prisms[i]);
        sprintf(msg, "(prism %d) expected volume %g, got %g", i, expect, res);
        mu_assert_almost_equals(res/expect, 1., 0.001, msg);
    }

    return 0;
}