#include #include #include /* For M_PI */ /* From Google maps. Probably not very accurate, but should be good enough for * this calculation. */ double latitude = 46.471857; double longitude = -81.186755; /* Radius of the earth in mm. */ double radius_earth = 6.371e9; /* Depth of the SNO detector in mm. Don't be fooled by all the digits. I just * converted 6800 feet -> mm. */ double sno_depth = 2072640; /* Fiducial volume in mm. */ double radius_fiducial = 5000; double deg2rad(double deg) { return deg*M_PI/180.0; } double rad2deg(double rad) { return rad*180.0/M_PI; } /* Convert spherical coordinates to cartesian coordinates. * * See https://en.wikipedia.org/wiki/Spherical_coordinate_system. */ void sphere2cartesian(double r, double theta, double phi, double *x, double *y, double *z) { *x = r*sin(theta)*cos(phi); *y = r*sin(theta)*sin(phi); *z = r*cos(theta); } /* Convert cartesian coordinates to spherical coordinates. * * See https://en.wikipedia.org/wiki/Spherical_coordinate_system. */ void cartesian2sphere(double x, double y, double z, double *r, double *theta, double *phi) { *r = sqrt(x*x + y*y + z*z); *theta = acos(z/(*r)); *phi = atan2(y,x); } int main(int argc, char **argv) { /* Spherical angles for the SNO detector in the earth frame which has z * along the north and south poles and the x axis passing through Greenwich. * Should double check this. */ double sno_theta = deg2rad(latitude + 90.0); double sno_phi = deg2rad(longitude); return 0; }