Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
ezzatron committed Apr 28, 2024
1 parent 7db988e commit e204f5b
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/n_E2R_EN.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,27 +17,30 @@ export function n_E2R_EN(
// Based on https://github.com/pbrod/nvector/blob/b8afd89a860a4958d499789607aacb4168dcef87/src/nvector/rotation.py#L478
const [n_e_x, n_e_y, n_e_z] = rotate(R_Ee, n_E);

// Nz_e = -n_e
// The z-axis of N (down) points opposite to n-vector
const Nz_e_x = -n_e_x;
const Nz_e_y = -n_e_y;
const Nz_e_z = -n_e_z;

// Ny_e_direction = np.cross([[1], [0], [0]], n_e, axis=0)
// Find y-axis of N (East)
// Remember that N is singular at poles
// Ny points perpendicular to the plane formed by n-vector and Earth's spin
// axis
const Ny_e_direction_y = -n_e_z;
const Ny_e_direction_z = n_e_y;

const Ny_e_direction_norm = Math.hypot(Ny_e_direction_y, Ny_e_direction_z);
const on_poles = Math.hypot(Ny_e_direction_y, Ny_e_direction_z) === 0;

// Unit vector
// Ny_e_x is always 0, so it's factored out in the following equations
const Ny_e_y = on_poles ? 1 : Ny_e_direction_y / Ny_e_direction_norm;
const Ny_e_z = on_poles ? 0 : Ny_e_direction_z / Ny_e_direction_norm;

// Nx_e = np.cross(Ny_e, Nz_e, axis=0)
// Find x-axis of N (North)
const Nx_e_x = Ny_e_y * Nz_e_z - Ny_e_z * Nz_e_y;
const Nx_e_y = Ny_e_z * Nz_e_x;
const Nx_e_z = -Ny_e_y * Nz_e_x;

// Use each component as a column vector, then multiply by the transpose of
// R_Ee to get the rotation matrix R_EN
return multiplyTransposed(R_Ee, [
[Nx_e_x, 0, Nz_e_x],
[Nx_e_y, Ny_e_y, Nz_e_y],
Expand Down

0 comments on commit e204f5b

Please sign in to comment.