Skip to main content

Crate geo4d

Crate geo4d 

Source
Expand description

4D (spatio-temporal) geodesy in pure f64, built on geo3d.

The fourth dimension is time. geo3d answers where is this?; geo4d answers where is this, when is it there, and how does the Earth itself move underneath it in the meantime? It adds the time axis to the 3D geometry and nothing else — the ellipsoids, ECEF/ENU frames, geodesics and static volumes are geo3d’s, re-exported here so a program needs only one dependency.

  • Epoch / Duration — a high-precision atomic clock: nanosecond-exact, Ord, stored on TAI so arithmetic never trips over leap seconds. Converts to and from Gps, Tt, Utc, Julian dates, GPS week/time-of-week, calendars and ITRF decimal years.
  • Geodetic4 / Ecef4 / StateVector — a position, or a position and velocity, bound to an Epoch. A point is not a point in space-time until it carries a time.
  • Trajectory — a time-ordered path with linear, cubic-Hermite or CatmullRom interpolation and an explicit Extrapolation policy.
  • PlateMotion / Helmert14 — the Earth moving: propagate a coordinate across epochs along its tectonic plate (ITRF2020 model), and transform between time-dependent reference frames (ITRF, GDA2020) with a 14-parameter Helmert.
  • closest_approach, conflict, intercept, collision_probability — 4D kinematics in absolute time: time of closest approach, cylindrical conflict windows, fixed-speed intercept, and the probability of collision (Chan’s series on the encounter plane).
  • Timed / Volume4 — box any geo3d volume into a TimeWindow for 4D geofencing, and test whether a Trajectory enters it.

Angles are degrees, lengths metres, times seconds (or a Duration) at the API. Everything except Trajectory is Copy and allocation-free, and the whole crate is #![forbid(unsafe_code)].

use geo4d::{conflict, Duration, Epoch, Geodetic4, ProtectedZone, TimeWindow};

// Two aircraft, each a position + course-over-ground at a shared time.
let now = Epoch::from_gregorian_utc(2026, 3, 14, 9, 30, 0.0);
let a = Geodetic4::from_lat_lon(-33.80, 151.30, 2_500.0, now)
    .state_from_course(geo4d::Course::new(225.0, 240.0, 0.0));   // SW at 240 m/s
let b = Geodetic4::from_lat_lon(-33.95, 151.10, 2_450.0, now)
    .state_from_course(geo4d::Course::new(45.0, 250.0, 0.0));    // NE at 250 m/s

// When do they pass closest, and is 5 NM / 1000 ft ever breached in the next 10 minutes?
let cpa = a.closest_approach(b);
let zone = ProtectedZone::new(9_260.0, 300.0);
let window = TimeWindow::for_duration(now, Duration::from_minutes(10.0));
if let Some(c) = a.conflict(b, zone, window) {
    assert!(c.enters >= now && c.duration().as_seconds() > 0.0);
}
assert!(cpa.tca >= now);

Re-exports§

pub use geo3d;

Modules§

eci
Earth-Centred Inertial ↔ Earth-Fixed, via Greenwich mean sidereal time.

Structs§

Aer
Azimuth-Elevation-Range: a pointing from an observer. Azimuth in degrees from north, clockwise, normalised to [0, 360); elevation in degrees above the local horizon; range in metres.
AltitudeBand
A vertical band of ellipsoidal heights, metres. A None bound is open on that side, so a floor-only or ceiling-only band works. Compose with any 2D footprint test for an extruded prism:
Cone
A right-circular cone: apex at a reference point, axis along an azimuth (degrees from north, clockwise) and elevation (degrees above the horizon), a half-angle spread and a slant range. A directional coverage volume — sector, field of view, beam, scan arc. The apex frame, axis and the half-angle cosine are computed once at construction.
Conflict
A predicted loss of separation: the interval during which two objects are simultaneously within the horizontal and vertical minima of a ProtectedZone.
Conjunction
The closest approach of two moving objects: when it happens and how near they pass.
Course
Motion over the ground at a position: course (true track) in degrees from north clockwise, ground speed and climb rate in m/s — the shape ADS-B, AIS and GNSS receivers report.
Covariance3
A 3×3 position covariance (metres²), symmetric. Add two together for a combined covariance.
Cpa
The closest point of approach of two objects in linear motion.
Cylinder
A vertical cylinder: a circular footprint of radius_m about a centre, extruded through an AltitudeBand — a circular airspace, a geofence with a height range, a well-defined “within R of the site between these heights”. Horizontal distance is measured in the centre’s local tangent plane, so it is a flat-Earth approximation valid for radii up to a few hundred km.
Duration
A signed span of time, stored as whole nanoseconds. Exact, Ord, and about ±5.4×10²¹ years of range — so it never overflows or drifts the way f64 seconds would over long baselines.
Ecef
An Earth-Centred, Earth-Fixed Cartesian position, metres. x through the equator/prime meridian, z through the north pole.
Ecef4
An Earth-Centred Earth-Fixed position at an instant.
Eci
An Earth-Centred Inertial position (metres): ECEF rotated by the sidereal angle, see crate::eci.
Ellipsoid
A reference ellipsoid of revolution: semi-major axis a (metres) and flattening f.
Enu
A vector in a local East-North-Up frame, metres (see LocalFrame).
Epoch
One instant in time, to the nanosecond. Stored internally on the uniform TAI scale, so comparisons and differences are exact integer operations regardless of leap seconds; scales, calendars and Julian dates are produced only at the boundary.
Geodesic
The shortest path between two positions on the ellipsoid surface.
Geodetic
A geodetic position: latitude and longitude in degrees, height in metres above the ellipsoid (ellipsoidal height, not orthometric/MSL).
Geodetic4
A geodetic position (latitude, longitude, height) at an instant. The “where and when” of a fix, a waypoint or a report.
Helmert7
A 7-parameter Helmert (Bursa-Wolf) transformation between ECEF frames: translations (metres), rotations (radians) and a scale factor (unitless, e.g. ppm × 1e-6).
Helmert14
A 14-parameter time-dependent Helmert transformation between two reference frames: the seven Helmert7 parameters plus a rate for each, referred to an epoch t₀. The parameters at epoch t are P(t) = P(t₀) + Ṗ·(t − t₀), so the transform is evaluated at the coordinate’s epoch before it is applied.
Intercept
A solved intercept: when and where a moving target is reached, and the velocity to do it with.
LocalFrame
An East-North-Up frame anchored at a reference point on an ellipsoid.
Ned
A vector in a local North-East-Down frame, metres (the aerospace convention).
PlateMotion
The rigid rotation of a tectonic plate, as an Euler angular-velocity vector Ω in ECEF (radians per Julian year). A site at ECEF position R moves at V = Ω × R (metres per year), which is how a plate-fixed coordinate is carried through a global frame like ITRF.
ProtectedZone
A cylindrical protected zone: a horizontal separation minimum and a vertical separation minimum, the shape aviation and drone-traffic (UTM) separation standards use.
Sphere
A sphere about a geodetic centre — a range/coverage bubble. The centre’s ECEF position is computed once at construction.
StateVector
A moving object at an instant: an ECEF position (metres) and velocity (metres per second), stamped with the Epoch they are valid at. Constant velocity is assumed between updates, so a state vector dead-reckons to any other epoch.
TimeWindow
A span of time between two Epochs, either end optionally open. The temporal half of 4D geofencing and the search bound for conflict prediction: a restriction that only holds [start, end).
Timed
A 3D Volume that is only active during a TimeWindow — the building block of 4D geofencing.
Track
A moving object: ECEF position (metres) and velocity (m/s), assumed constant.
Trajectory
A time-ordered path with an interpolation and an extrapolation policy. Waypoints are kept sorted and strictly increasing in time.
Vec3
A Cartesian 3-vector (metres, or unitless for directions).
Waypoint
One sample on a Trajectory: a position at an epoch, optionally with a known velocity (which Hermite interpolation uses as the tangent).

Enums§

Extrapolation
What a query outside the sampled span returns.
Interpolation
How a position is read between samples.
TimeScale
A time scale that Epochs convert to and from at the API. The internal storage is always TAI.
TrajectoryError
Why a trajectory could not be built or extended.

Constants§

AIRY_1830
Airy 1830 (OSGB36).
BESSEL_1841
Bessel 1841.
CLARKE_1866
Clarke 1866 (NAD27).
GRS80
GRS 80 — the ellipsoid under most modern national datums (NAD83, GDA94/2020, ETRS89).
INTERNATIONAL_1924
International 1924 (Hayford).
PZ90
PZ-90 (GLONASS).
WGS72
WGS 72.
WGS84
WGS 84 — GPS, and the frame CesiumJS renders in.

Traits§

Volume
Something that can decide whether a geodetic point is inside it.
Volume4
Something that can decide whether a timestamped point is inside it — the 4D counterpart of geo3d’s Volume.

Functions§

closest_approach
The closest point of approach of two state vectors, in absolute time. Each is propagated to a common epoch first, so they need not be sampled simultaneously. A first-order estimate: compare distance_m with a separation threshold.
closest_approach_within
The closest approach restricted to a time window — the nearest they pass while the window is open. Because separation is convex in time, this is the unconstrained TCA clamped into the window (no second solve).
collision_probability
The probability that two objects collide at their close approach, in [0, 1]. cov_a and cov_b are each object’s position covariance (metres², ECEF); hard_body_radius_m is the sum of the two object radii. Uses Chan’s series on the 2D encounter-plane integral.
conflict
Whether and when two objects violate a cylindrical ProtectedZone, searched over window (pass TimeWindow::unbounded for all time). Horizontal and vertical are separated in a local East-North-Up frame at the first object’s position — an approximation good for the minutes-scale look-ahead of conflict detection, where the frame’s rotation is negligible.
intercept
The earliest fixed-speed intercept of a moving target by an interceptor launching from origin (at origin’s epoch) with the given constant speed_mps, heading free — the “lead collision” solution. None if the target cannot be caught at that speed (it is faster and opening, or the geometry is unreachable).
on_collision_course
Whether two objects are on a collision course: their closest approach is within miss_tol_m and still ahead (constant bearing, decreasing range). A cheap early-out before a full solve.