This commit is contained in:
2026-02-05 10:35:24 +03:00
parent 593a914d8d
commit 6352865610
3 changed files with 49 additions and 21 deletions

View File

@@ -18,11 +18,11 @@
namespace mcc
{
constexpr double MCC_DEGRESS_TO_RADS = std::numbers::pi / 180.0;
constexpr double MCC_RADS_TO_DEGRESS = 1.0 / MCC_DEGRESS_TO_RADS;
static constexpr double MCC_DEGRESS_TO_RADS = std::numbers::pi / 180.0;
static constexpr double MCC_RADS_TO_DEGRESS = 1.0 / MCC_DEGRESS_TO_RADS;
constexpr double MCC_HALF_PI = std::numbers::pi / 2.0;
constexpr double MCC_TWO_PI = std::numbers::pi * 2.0;
static constexpr double MCC_HALF_PI = std::numbers::pi / 2.0;
static constexpr double MCC_TWO_PI = std::numbers::pi * 2.0;
static constexpr double MCC_SIDERAL_TO_UT1_RATIO = 1.002737909350795; // sideral/UT1

View File

@@ -659,30 +659,30 @@ protected:
// HA, DEC to AZ, ALT (AZ from the South through the West)
void hadec2azalt(double ha, double dec, double phi, double& az, double& alt) const
{
eraHd2ae(ha, dec, phi, &az, &alt);
// from ERFA "from N" to "from S"
if (az > std::numbers::pi) {
az -= std::numbers::pi;
} else {
az += std::numbers::pi;
}
// eraHd2ae(ha, dec, phi, &az, &alt);
// // from ERFA "from N" to "from S"
// if (az > std::numbers::pi) {
// az -= std::numbers::pi;
// } else {
// az += std::numbers::pi;
// }
return;
// return;
const auto cos_phi = std::cos(phi), sin_phi = std::sin(phi);
const auto cos_dec = std::cos(dec), sin_dec = std::sin(dec);
const auto cos_ha = std::cos(ha), sin_ha = std::sin(ha);
auto x = sin_phi * cos_dec * cos_ha - cos_phi * sin_dec;
auto y = -cos_dec * sin_ha;
auto y = cos_dec * sin_ha;
auto z = cos_phi * cos_dec * cos_ha + sin_phi * sin_dec;
auto xx = x * x, yy = y * y;
decltype(x) r;
if (xx < yy) {
r = yy * sqrt(1.0 + xx / yy);
r = std::abs(y) * sqrt(1.0 + xx / yy);
} else {
r = xx * sqrt(1.0 + yy / xx);
r = std::abs(x) * sqrt(1.0 + yy / xx);
}
az = utils::isEqual(r, 0.0) ? 0.0 : std::atan2(y, x);
@@ -697,10 +697,10 @@ protected:
// AZ, ALT to HA, DEC (AZ from the South through the West)
void azalt2hadec(double az, double alt, double phi, double& ha, double& dec) const
{
az += std::numbers::pi;
eraAe2hd(az, alt, phi, &ha, &dec);
// az += std::numbers::pi;
// eraAe2hd(az, alt, phi, &ha, &dec);
return;
// return;
const auto cos_phi = std::cos(phi), sin_phi = std::sin(phi);
const auto cos_az = std::cos(az), sin_az = std::sin(az);
@@ -713,9 +713,9 @@ protected:
auto xx = x * x, yy = y * y;
decltype(x) r;
if (xx < yy) {
r = yy * sqrt(1.0 + xx / yy);
r = std::abs(y) * sqrt(1.0 + xx / yy);
} else {
r = xx * sqrt(1.0 + yy / xx);
r = std::abs(x) * sqrt(1.0 + yy / xx);
}
ha = utils::isEqual(r, 0.0) ? 0.0 : std::atan2(y, x);

View File

@@ -439,8 +439,36 @@ struct MccSerializer<VT> : MccSerializerBase {
pars.norm_sxgm = true;
pars.coordpair_format = MccSerializedCoordPairFormat::MCC_SERIALIZED_FORMAT_SXGM_HOURDEG;
// RA_OBS_MOUNT
std::string ra_obs, ra_app, ha, last, ra_app_tg;
MccSkyRADEC_OBS r_obs;
MccSkyRADEC_APP r_app;
// quantities in hour representation
MccSerializerBase::angleFormatFromCoordPairType<VT::pairKind, MccSerializerBase::CO_LON>(pars);
MccSerializer<MccAngle> ang_sr;
// RA_OBS_MOUNT
auto ccte_err = value.mountPos.toAtSameEpoch(r_obs);
if (ccte_err) {
return mcc_deduced_err(ccte_err, MccSerializerErrorCode::ERROR_COORD_TRANSFORM);
}
auto err = ang_sr(ra_obs, r_obs, pars);
if (err) {
return mcc_deduced_err(err, MccSerializerErrorCode::ERROR_UNDERLYING_SERIALIZER);
}
// RA_APP_MOUNT
ccte_err = value.mountPos.toAtSameEpoch(r_app);
if (ccte_err) {
return mcc_deduced_err(ccte_err, MccSerializerErrorCode::ERROR_COORD_TRANSFORM);
}
err = ang_sr(ra_app, r_app, pars);
if (err) {
return mcc_deduced_err(err, MccSerializerErrorCode::ERROR_UNDERLYING_SERIALIZER);
}
}
};