double approximate_az_from_cross_el(double cross_el, double el) { if (el >= from_degrees(0.0) && el < from_degrees(85.0)) { return cross_el / cos(el); } return cross_el; }
void horizontal_to_equatorial(double az_deg, double el_deg, time_t lst_s, double lat_deg, double* ra_hours, double* dec_deg) { double ha = 0.0; double dec = 0.0; double sa, ca, se, ce, sp, cp, x, y, z, r; sincos(from_degrees(az_deg), &sa, &ca); sincos(from_degrees(el_deg), &se, &ce); sincos(from_degrees(lat_deg), &sp, &cp); /* HA,Dec as x,y,z */ x = -ca * ce * sp + se * cp; y = -sa * ce; z = ca * ce * cp + se * sp; /* To spherical */ r = sqrt(x * x + y * y); ha = (r == 0.0) ? 0.0 : atan2(y, x); dec = atan2(z, r); *ra_hours = to_hours(from_seconds(lst_s) - ha); *ra_hours = wrap_to(*ra_hours, 24.0); *dec_deg = to_degrees(dec); }
static bool decode(const Node& node, Calibration& calibration) { if(!node.IsMap()) { ROS_ERROR("Error, calibration does not contain key value pairs, i.e. min_pulse, min_angle, max_pulse and max_angle"); return false; } else if(!node["min_pulse"]) { ROS_ERROR("Error, calibration min_pulse not specified"); return false; } else if(!node["min_angle"]) { ROS_ERROR("Error, calibration min_angle not specified"); return false; } else if(!node["max_pulse"]) { ROS_ERROR("Error, calibration max_pulse not specified"); return false; } else if(!node["max_angle"]) { ROS_ERROR("Error, calibration max_angle not specified"); return false; } calibration.min_pulse = node["min_pulse"].as<int>(); calibration.min_angle = from_degrees(node["min_angle"].as<double>()); calibration.max_pulse = node["max_pulse"].as<int>(); calibration.max_angle = from_degrees(node["max_angle"].as<double>()); return true; }
void equatorial_to_horizontal(double ra_hours, double dec_deg, time_t lst_s, double lat_deg, double* az_deg, double* el_deg) { double ha = from_seconds(lst_s) - from_hours(ra_hours); double sh, ch, sd, cd, sp, cp, x, y, z, r, a; sincos(ha, &sh, &ch); sincos(from_degrees(dec_deg), &sd, &cd); sincos(from_degrees(lat_deg), &sp, &cp); /* Az,El as x,y,z */ x = -ch * cd * sp + sd * cp; y = -sh * cd; z = ch * cd * cp + sd * sp; /* To spherical */ r = sqrt(x * x + y * y); a = (fabs(r) < DBL_MIN) ? 0.0 : atan2(y, x); *az_deg = to_degrees((a < 0.0) ? a + (2.0 * M_PI) : a); *el_deg = to_degrees(atan2(z, r)); }