CosmosCoordinates
Frame rotations and spherical astronomy. Depends on CosmosCore, CosmosMath, CosmosTime.
All angles are radians, lengths metres; matrices follow the frame-rotation convention of CosmosMath.Rotation.
What is implemented
| File | Main API |
|---|---|
Frames.swift |
Frames.icrfToEclipticJ2000, icrfToGalactic, obliquityJ2000, constantRotation(from:to:), rotation(from:to:at:bodyFixed:), transform(_:from:to:), sphericalCoordinates(rightAscension:declination:in:), equatorialCoordinates(longitude:latitude:in:); FrameRotation (matrix + derivative); protocol BodyFixedRotationProvider; StateVector.expressed(in:bodyFixed:) |
EarthOrientation.swift |
EarthModels (pure IAU models of explicit TT/UT1 arguments) and EarthOrientation (same at an Instant; implements BodyFixedRotationProvider for naif:399) |
Geodesy.swift |
Ellipsoid (.wgs84, .grs80), GeodeticPosition, Geodesy.earthFixed, geodetic(earthFixed:), eastNorthUpMatrix; HorizontalCoordinates; Topocentric.horizontal, hourAngleDeclination, parallacticAngle, hourAngle, equatorial; EarthOrientation.horizontal(ofICRFDirection:site:at:), icrfDirection(of:site:at:), icrfToEastNorthUp, observerState(site:at:) |
Sexagesimal.swift |
Sexagesimal.parseRightAscension, parseDeclination, parseCoordinates, formatRightAscension, formatDeclination, formatDegrees |
ProperMotion.swift |
StarAstrometry, ProperMotion.propagate(_:toEpoch:) → PropagatedStar (with ProperMotionMethod), ProperMotion.direction(of:atEpoch:) |
Models and references
Constant frames
- Ecliptic J2000: rotation of 84381.448″ about x — SPICE
ECLIPJ2000(IAU 1976 obliquity). - Galactic (IAU 1958): built as SPICE builds
GALACTIC: J2000 → B1950[1152.84248596724″]₃[−1002.26108439117″]₂[1153.04066200330″]₃, B1950 → FK4[0.525″]₃, FK4 → galactic[327°]₃[62.6°]₁[282.25°]₃. The angles were read back from CSPICE N0067 (pxform+m2eul) and the resulting matrix is compared with CSPICE in the tests. It differs by 3.3 mas (measured at the ERFA test direction) from the Hipparcos-based matrix of ERFAeraIcrs2g. ReferenceFrame.icrfis treated as J2000 for these constant frames (no frame bias), as stated inCosmosCore.
Earth orientation
| Quantity | Model | Reference implementation followed |
|---|---|---|
| Mean obliquity | IAU 2006 | ERFA eraObl06 |
| Precession (with ICRS frame bias) | IAU 2006, Fukushima–Williams angles | eraPfw06, eraFw2m, eraPmat06, eraBp06 |
| Nutation | IAU 2000B (77 luni-solar terms + fixed planetary offset), not 2000A | eraNut00b |
| Earth rotation angle | IAU 2000 | eraEra00 |
| GMST | IAU 2006 | eraGmst06 |
| Equation of the equinoxes | Δψ·cos ε_A + complementary terms (IERS 2003) | eraEect00, fundamental arguments eraFal03 … eraFapa03 |
| GAST | GMST + equation of the equinoxes (equinox-based) | — |
Rotations: icrfToMeanOfDate (bias + precession), precessionMatrix (J2000 mean → mean of date, no bias),
icrfToTrueOfDate (bias, precession, nutation), trueOfDateToEarthFixed = R₃(GAST), icrfToEarthFixed
(FrameRotation, derivative = Earth spin 7.292115e-5 rad/s from the ERA rate). Unlike the constant frames, the
Earth-orientation chain does include the ≈23 mas ICRS frame bias, as the IAU models require.
Time arguments: TT from TimeSystem.julianCenturiesTT, UT1 from TimeSystem.ut1 (whose source/status is exposed by
EarthOrientation.rotationStatus).
Ignored, by design: polar motion (≈0.3″, ≈10 m on the ground), celestial pole offsets dX/dY (< 1 mas), sub-daily UT1 tides, the s′ locator, the deflection of the vertical, and the geoid (heights are ellipsoidal). "Earth-fixed" is therefore the terrestrial intermediate frame, within 0.3″ of ITRF.
Geodesy and horizon
WGS 84 (a = 6378137 m, 1/f = 298.257223563). Geodetic → Cartesian closed form (eraGd2gce); Cartesian → geodetic
by Fukushima (2006) (eraGc2gde). East-north-up matrix from geodetic longitude/latitude. Azimuth is measured from
north through east; altitude is geometric (no atmospheric refraction — that belongs to CosmosObservation).
eraHd2ae, eraAe2hd, eraHd2pa are followed for hour angle/declination ↔ azimuth/altitude and the parallactic angle.
Sexagesimal text
Rules are stated in the Sexagesimal doc comment. In short: RA with h, colons or several fields is in hours;
RA as one plain decimal number or with °/d is in degrees; Dec is always degrees; in a pair the declination
starts at its sign, otherwise 2/4/6 numeric fields are split evenly. Out-of-range or ambiguous input throws
CosmosError.invalidInput (never a guess). Formatting rounds with full carry and never prints "−0".
Proper motion
StarAstrometry stores α, δ, μα* (with cos δ), μδ, optional parallax and radial velocity, and the Julian epoch.
- Parallax > 0 and radial velocity present →
rigorousSpaceMotion: port of ERFAeraStarpv/eraPvstar/eraStarpm(space motion, perspective acceleration, light-time change, relativistic Doppler terms). - Otherwise →
linearTangential: great-circle motion at constant |μ|; parallax and radial velocity are passed through unchanged (nil stays nil). Non-positive parallaxes (they exist in Gaia) are treated as unknown distance. The method used is always returned. No aberration, parallax shift or light deflection is applied here.
Body-fixed frames
ReferenceFrame.bodyFixed is resolved through BodyFixedRotationProvider.rotationFromICRF(toBodyFixed:at:)
(matrix and time derivative). This module provides it for the Earth only (EarthOrientation); planetary rotation
models belong to CosmosEphemeris, which should conform a type to the protocol. Without a provider,
Frames.rotation / StateVector.expressed throw CosmosError.unsupported.
Validation and tolerances (tests: Packages/CosmosCoordinates/Tests, 25 tests)
| Check | Reference | Tolerance | Measured / why |
|---|---|---|---|
| J2000→ECLIPJ2000, J2000→GALACTIC, ECLIPJ2000→GALACTIC matrices | CSPICE N0067 pxform (spice_frames_reference.json) |
1e-15 | 0, 1.1e-16, 1.1e-16 (1 ulp) |
| galactic coordinates | ERFA t_icrs2g (Hipparcos matrix) |
20 mas | 3.3 mas: two different definitions |
| obliquity, F-W angles, F-W matrix | ERFA t_obl06, t_pfw06, t_fw2m |
1e-14 / 1e-12…1e-16 / 1e-12 | ERFA's own tolerances |
| bias, precession, bias-precession matrices | ERFA t_bp06, t_pmat06 |
1e-14 | ERFA's own tolerance on off-diagonal terms |
| nutation 2000B | ERFA t_nut00b |
1e-13 rad | ERFA's own tolerance |
| complementary terms, ERA, GMST, fundamental argument | ERFA t_eect00, t_era00, t_gmst06, t_fal03 |
1e-20, 1e-12, 1e-12, 1e-12 | ERFA's own tolerances |
| NPB matrix (2006 + 2000B) vs IAU 2006/2000A | ERFA t_pnm06a |
1 mas | 0.35 mas — the stated 2000B − 2000A accuracy is 1 mas for 1995–2050 |
| GAST, equation of the equinoxes vs 2006/2000A | ERFA t_gst06a, t_ee06a |
1 mas | −0.31 mas (= 21 µs of time) |
| geodetic ↔ Cartesian | ERFA t_gd2gc, t_gc2gd (WGS84, GRS80) |
1e-7 m / 1e-14 rad, 1e-8 m | ERFA's own tolerances |
| geodetic round trip (2000 points, −11 km … 40 000 km) | property | 1e-10 rad, 1e-6 m | 2.6e-11 rad, 1.5e-8 m |
| site Cartesian coordinates | JPL Horizons header (cylindrical, km, 5 decimals) | 1 cm | 0.08 cm, 0.34 cm |
| (h, δ) ↔ (az, alt), parallactic angle | ERFA t_hd2ae, t_ae2hd, t_hd2pa |
1e-13 / 1e-14 | ERFA's own tolerances |
| Local apparent sidereal time (5 epochs 2024, Cerro Pachón) | JPL Horizons quantity 7, with IERS UT1 − UTC | 0.05 s of time | 7.7 ms (0.12″): polar motion ignored (≈0.3″) + Horizons' IAU 76/80 equinox offset (53 mas) |
| az/el from Horizons apparent RA/Dec + Horizons LAST | JPL Horizons quantity 4 | 1″ | 2.5e-6″ (pure geometry) |
| az/el end to end (UTC → UT1 → GAST → LAST → az/el) | JPL Horizons quantity 4 | 1″ | 0.11″ |
| same, without Earth-orientation table (ΔT model) | JPL Horizons | 10 s (sanity bound) | LAST off by 5.3 s — see CosmosTime |
| rigorous proper motion | ERFA t_starpm |
1e-13 rad, 1e-17 rad/yr, 1e-13″, 1e-11 km/s | ERFA's own tolerances |
| linear proper motion: arc = | μ | Δt, reversibility | property |
| rigorous vs linear, 10.4″/yr star at 1.83 pc, −110.5 km/s, 50 yr | — | 0.01″ … 5″ | 1.6″: size of the perspective acceleration that the linear method omits |
| sexagesimal text round trip (1000 random, two styles) | property | half a unit of the last digit | |
| Earth-fixed state of a ground site: zero velocity, ω·ρ inertial speed, Ṁ vs finite difference | property | 1e-9 m/s, 1e-10 s⁻¹ |
Fixtures and their URLs/dates: Packages/CosmosCoordinates/Tests/Fixtures/README.txt.
Known limits
- Nutation is IAU 2000B: ≈1 mas-class up to 2050, degrading slowly outside; precession polynomials are intended
for a few centuries around J2000 (IAU 2006 is not a long-term model; millennia away the error grows to
arcminutes and more). No validity gate is enforced on the date: callers showing Earth orientation far from the
present should say so (the dominant error there is ΔT, flagged by
TimeSystem.validity). - Earth rotation accuracy is set by UT1: milliseconds with an IERS table, seconds (tens of arcseconds) with the ΔT model, far more in the distant past/future.
- No polar motion, no refraction, no aberration/light-time/deflection (those are applied by the ephemeris and observation modules before calling the geometric functions here).
FrameRotation.derivativefor the Earth neglects precession/nutation rates (1e-7 of the spin: < 0.05 mm/s at the surface).- Proper-motion
rigorousSpaceMotionrefuses data implying speeds above 0.5 c and stars exactly at a pole (falls back to linear); the linear method ignores perspective acceleration. - The galactic frame is SPICE's (IAU 1958 via FK4), not the Hipparcos/ICRS-defined matrix; the difference is a few mas.
- Ecliptic-of-date, supergalactic and FK4/B1950 frames are not provided.