diff options
-rw-r--r-- | .gitignore | 2 | ||||
-rw-r--r-- | Makefile | 3 | ||||
-rw-r--r-- | calculate_limits.c | 59 |
3 files changed, 64 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d17415b --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +*.swp +calculate_limits diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..8f1188a --- /dev/null +++ b/Makefile @@ -0,0 +1,3 @@ +LDLIBS=-lm + +calculate_limits: calculate_limits.c diff --git a/calculate_limits.c b/calculate_limits.c new file mode 100644 index 0000000..8815324 --- /dev/null +++ b/calculate_limits.c @@ -0,0 +1,59 @@ +#include <stdio.h> +#include <gsl/gsl_integration.h> +#include <math.h> /* 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; +} |