404 const double theta0 = M_PI/2-d*M_PI/180;
405 const double phi0 = r*M_PI/12;
407 const double theta1 = M_PI/2-
dec*M_PI/180;
408 const double phi1 =
ra*M_PI/12;
410 const double x0 = sin(theta0) * cos(phi0);
411 const double y0 = sin(theta0) * sin(phi0);
412 const double z0 = cos(theta0);
414 const double x1 = sin(theta1) * cos(phi1);
415 const double y1 = sin(theta1) * sin(phi1);
416 const double z1 = cos(theta1);
418 double arg = x0*x1 + y0*y1 + z0*z1;
419 if(arg > 1.0) arg = 1.0;
420 if(arg < -1.0) arg = -1.0;
422 return acos(arg) * 180/M_PI;