#![cfg(feature = "std")]
use supernovas::{
Accuracy, CatalogEntry, Equatorial, Equinox, Frame, Observer, ReferenceSystem, Time,
};
const NGP_RA_DEG: f64 = 192.859_48;
const NGP_DEC_DEG: f64 = 27.128_25;
const GC_RA_DEG: f64 = 266.404_99;
const GC_DEC_DEG: f64 = -28.936_17;
fn deg_diff(a: f64, b: f64) -> f64 {
let d = (a - b).rem_euclid(360.0);
if d > 180.0 { 360.0 - d } else { d }
}
#[test]
fn north_galactic_pole_maps_to_b_plus_90() {
let ngp = Equatorial::from_degrees(NGP_RA_DEG, NGP_DEC_DEG, Equinox::ICRS).unwrap();
let g = ngp.to_galactic(Accuracy::Reduced).unwrap();
let off_arcsec = (90.0 - g.b().deg()).abs() * 3600.0;
assert!(
off_arcsec < 5.0,
"NGP should map to b=+90°, got b={}° ({off_arcsec}″ off)",
g.b().deg()
);
}
#[test]
fn galactic_center_maps_to_origin() {
let gc = Equatorial::from_degrees(GC_RA_DEG, GC_DEC_DEG, Equinox::ICRS).unwrap();
let g = gc.to_galactic(Accuracy::Reduced).unwrap();
let l_off = deg_diff(g.l().deg(), 0.0);
let b_off = g.b().deg().abs();
assert!(
l_off < 0.05,
"galactic center should map to l=0, got l={}° ({l_off}° off)",
g.l().deg()
);
assert!(
b_off < 0.05,
"galactic center should map to b=0, got b={}°",
g.b().deg()
);
}
#[test]
fn annual_aberration_magnitude_is_physical() {
let ra_h = 18.0 + 36.0 / 60.0 + 56.336 / 3600.0; let dec_d = 38.0 + 47.0 / 60.0 + 1.28 / 3600.0;
let catalog = Equatorial::from_hours_and_degrees(ra_h, dec_d, Equinox::ICRS).unwrap();
let frame = Frame::new(
Accuracy::Reduced,
&Observer::Geocenter,
&Time::from_utc_jd(2_461_236.75, 37, 0.0).unwrap(),
)
.unwrap();
let apparent = CatalogEntry::icrs("Vega", catalog.ra(), catalog.dec())
.unwrap()
.apparent_in(&frame, ReferenceSystem::Gcrs)
.unwrap();
let sep_arcsec = catalog.distance_to(apparent.equatorial()).arcsec();
assert!(
(1.0..=20.6).contains(&sep_arcsec),
"GCRS aberration offset {sep_arcsec}″ outside the physical (1″, κ=20.4955″] range"
);
}