1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
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;
}
|