Skip to content

EQW Frame

The equinoctial frame EQW places E along the ascending node, W along the orbit normal, and \(Q = W \times E\), so a satellite's own position is \(r[\cos u, \sin u, 0]\) with \(u\) the argument of latitude. On an equatorial orbit E is taken along the inertial x axis projected into the orbit plane.

import numpy as np

import brahe as bh

bh.initialize_eop()

oe = np.array([bh.R_EARTH + 700e3, 0.1, 97.8, 15.0, 30.0, 45.0])
x_ecc = bh.state_koe_to_eci(oe, bh.AngleFormat.DEGREES)
e_eqw = bh.rotation_eqw_to_eci(x_ecc)[:, 0]
raan = np.radians(15.0)
print(
    "E equals [cos Omega, sin Omega, 0]:",
    np.allclose(e_eqw, np.array([np.cos(raan), np.sin(raan), 0.0]), atol=1e-6),
)

r_eqw = bh.rotation_eci_to_eqw(x_ecc) @ x_ecc[:3]
r = np.linalg.norm(x_ecc[:3])
f = np.radians(bh.anomaly_mean_to_true(45.0, 0.1, angle_format=bh.AngleFormat.DEGREES))
u = np.radians(30.0) + f
print(
    "Own position in EQW equals r [cos u, sin u, 0]:",
    np.allclose(r_eqw, r * np.array([np.cos(u), np.sin(u), 0.0]), atol=1e-6),
)

# Equatorial orbit: the node is undefined, E falls back to the inertial x axis
oe_equatorial = np.array([bh.R_EARTH + 700e3, 0.1, 0.0, 15.0, 30.0, 45.0])
x_equatorial = bh.state_koe_to_eci(oe_equatorial, bh.AngleFormat.DEGREES)
e_equatorial = bh.rotation_eqw_to_eci(x_equatorial)[:, 0]
print(
    "Equatorial fallback: E equals [1, 0, 0]:",
    np.allclose(e_equatorial, np.array([1.0, 0.0, 0.0]), atol=1e-6),
)

# Frame graph
epc = bh.Epoch.from_datetime(2024, 3, 1, 0, 0, 0.0, 0.0, bh.UTC)
bh.register_object("SC", lambda epoch: x_ecc, bh.CelestialFrame.GCRF)
r_graph = bh.rotation_frame_to_frame(
    bh.CelestialFrame.GCRF, bh.ReferenceFrame.EQW("SC"), epc
)
print(
    "Frame graph matches rotation_eci_to_eqw:",
    np.allclose(r_graph, bh.rotation_eci_to_eqw(x_ecc)),
)
bh.clear_object_registry()
use brahe as bh;
use brahe::frames::{CelestialFrame, ReferenceFrame};
use brahe::time::{Epoch, TimeSystem};
use brahe::utils::BraheError;
use brahe::utils::state_providers::SStateProvider;
use nalgebra::Vector6;

/// A state provider returning a fixed state at every epoch, for registering
/// the spacecraft as an object.
struct ConstantProvider(Vector6<f64>);
impl SStateProvider for ConstantProvider {
    fn state(&self, _epoch: Epoch) -> Result<Vector6<f64>, BraheError> {
        Ok(self.0)
    }
}

fn main() {
    bh::initialize_eop().unwrap();

    let oe = Vector6::new(bh::R_EARTH + 700e3, 0.1, 97.8, 15.0, 30.0, 45.0);
    let x_ecc = bh::state_koe_to_eci(oe, bh::AngleFormat::Degrees);
    let e_eqw = bh::rotation_eqw_to_eci(x_ecc).column(0).into_owned();
    let raan = 15.0_f64.to_radians();
    println!(
        "E equals [cos Omega, sin Omega, 0]: {}",
        (e_eqw - nalgebra::Vector3::new(raan.cos(), raan.sin(), 0.0)).norm() < 1e-6
    );

    let r_eqw = bh::rotation_eci_to_eqw(x_ecc) * x_ecc.fixed_rows::<3>(0).into_owned();
    let r = x_ecc.fixed_rows::<3>(0).norm();
    let f = bh::anomaly_mean_to_true(45.0, 0.1, bh::AngleFormat::Degrees)
        .unwrap()
        .to_radians();
    let u = 30.0_f64.to_radians() + f;
    let r_argument_of_latitude = r * nalgebra::Vector3::new(u.cos(), u.sin(), 0.0);
    println!(
        "Own position in EQW equals r [cos u, sin u, 0]: {}",
        (r_eqw - r_argument_of_latitude).norm() < 1e-6
    );

    // Equatorial orbit: the node is undefined, E falls back to the inertial x axis
    let oe_equatorial = Vector6::new(bh::R_EARTH + 700e3, 0.1, 0.0, 15.0, 30.0, 45.0);
    let x_equatorial = bh::state_koe_to_eci(oe_equatorial, bh::AngleFormat::Degrees);
    let e_equatorial = bh::rotation_eqw_to_eci(x_equatorial)
        .column(0)
        .into_owned();
    println!(
        "Equatorial fallback: E equals [1, 0, 0]: {}",
        (e_equatorial - nalgebra::Vector3::new(1.0, 0.0, 0.0)).norm() < 1e-6
    );

    // Frame graph
    let epc = Epoch::from_datetime(2024, 3, 1, 0, 0, 0.0, 0.0, TimeSystem::UTC);
    bh::register_object("SC", ConstantProvider(x_ecc), CelestialFrame::GCRF).unwrap();
    let r_graph =
        bh::rotation_frame_to_frame(CelestialFrame::GCRF, ReferenceFrame::EQW("SC"), epc)
            .unwrap();
    println!(
        "Frame graph matches rotation_eci_to_eqw: {}",
        (r_graph - bh::rotation_eci_to_eqw(x_ecc)).norm() < 1e-12
    );
    bh::clear_object_registry();
}
Output
1
2
3
4
E equals [cos Omega, sin Omega, 0]: True
Own position in EQW equals r [cos u, sin u, 0]: True
Equatorial fallback: E equals [1, 0, 0]: True
Frame graph matches rotation_eci_to_eqw: True
1
2
3
4
E equals [cos Omega, sin Omega, 0]: true
Own position in EQW equals r [cos u, sin u, 0]: true
Equatorial fallback: E equals [1, 0, 0]: true
Frame graph matches rotation_eci_to_eqw: true

See Also