Skip to content

NSW Frame

rotation_nsw_to_eci builtin

rotation_nsw_to_eci(x_eci: Union[ndarray, Sequence], x_sun: Union[ndarray, Sequence], axis: int = -1) -> ndarray

Computes the rotation matrix transforming a vector in the Nadir, Sun, Normal (NSW) frame to the Earth-Centered Inertial (ECI) frame.

The ECI frame can be any inertial frame centered on the orbited body, such as GCRF or EME2000.

The NSW frame follows the SANA definition: - X: Unit vector toward nadir, opposite the position vector. - Y: As close to the direction of the Sun as possible while normal to X. With s the unit vector from the spacecraft to the Sun, this is the unit vector perpendicular to x that maximizes y . s, which is the Sun direction with its X component removed and renormalized: y = (s - (s . x) x) / |s - (s . x) x|. - Z: X x Y, completing the right-handed set.

x_sun is the Sun's state relative to the same center as x_eci. Because X lies along the position vector, the frame is identical whether the Sun direction is taken from the center or from the spacecraft. When the Sun lies along the nadir line (projected norm below 1e-9) the Y axis falls back to the along-track direction. The SANA definition does not cover that case; the fallback is specific to this implementation.

Parameters:

Name Type Description Default
x_eci ndarray or list

6D state vector in the ECI frame [x, y, z, vx, vy, vz] (m, m/s), shape (6,), or a batch of vectors with the 6 components along axis (for example shape (n, 6)).

required
x_sun ndarray or list

6D state vector of the Sun relative to the same center [x, y, z, vx, vy, vz] (m, m/s), shape (6,), or a batch of vectors with the 6 components along axis; only the position is used here.

required
axis int

The axis along which the 6 components of a single vector lie; the remaining axes enumerate the batch. For a batch of shape (n, 6) the components lie along the last axis, so the default -1 applies; a (6, n) column layout uses axis=0. A single vector in one argument is broadcast across a batch in the other.

-1

Returns:

Type Description
ndarray

numpy.ndarray: 3x3 rotation matrix transforming from NSW to ECI frame, shape (3, 3), or the batch dimensions followed by (3, 3) for batched input.

Example
1
2
3
4
5
6
7
8
9
import brahe as bh
import numpy as np

oe = np.array([bh.R_EARTH + 700e3, 0.01, 97.8, 15.0, 30.0, 45.0])
x_eci = bh.state_koe_to_eci(oe, bh.AngleFormat.DEGREES)
x_sun = np.array([bh.AU, 0.0, 0.0, 0.0, 0.0, 0.0])

R = bh.rotation_nsw_to_eci(x_eci, x_sun)
print(f"NSW to ECI rotation matrix:\n{R}")

rotation_eci_to_nsw builtin

rotation_eci_to_nsw(x_eci: Union[ndarray, Sequence], x_sun: Union[ndarray, Sequence], axis: int = -1) -> ndarray

Computes the rotation matrix transforming a vector in the Earth-Centered Inertial (ECI) frame to the Nadir, Sun, Normal (NSW) frame.

This is the transpose (inverse) of the NSW-to-ECI rotation matrix.

Parameters:

Name Type Description Default
x_eci ndarray or list

6D state vector in the ECI frame [x, y, z, vx, vy, vz] (m, m/s), shape (6,), or a batch of vectors with the 6 components along axis (for example shape (n, 6)).

required
x_sun ndarray or list

6D state vector of the Sun relative to the same center [x, y, z, vx, vy, vz] (m, m/s), shape (6,), or a batch of vectors with the 6 components along axis; only the position is used here.

required
axis int

The axis along which the 6 components of a single vector lie; the remaining axes enumerate the batch. For a batch of shape (n, 6) the components lie along the last axis, so the default -1 applies; a (6, n) column layout uses axis=0. A single vector in one argument is broadcast across a batch in the other.

-1

Returns:

Type Description
ndarray

numpy.ndarray: 3x3 rotation matrix transforming from ECI to NSW frame, shape (3, 3), or the batch dimensions followed by (3, 3) for batched input.

Example
1
2
3
4
5
6
7
8
9
import brahe as bh
import numpy as np

oe = np.array([bh.R_EARTH + 700e3, 0.01, 97.8, 15.0, 30.0, 45.0])
x_eci = bh.state_koe_to_eci(oe, bh.AngleFormat.DEGREES)
x_sun = np.array([bh.AU, 0.0, 0.0, 0.0, 0.0, 0.0])

R = bh.rotation_eci_to_nsw(x_eci, x_sun)
print(f"ECI to NSW rotation matrix:\n{R}")

omega_nsw builtin

omega_nsw(x_eci: Union[ndarray, Sequence], x_sun: Union[ndarray, Sequence], axis: int = -1) -> ndarray

Computes the angular velocity of the Nadir, Sun, Normal (NSW) frame with respect to the Earth-Centered Inertial (ECI) frame, expressed in NSW axes.

The SANA definition gives the axes but no rotation rate. The rate here follows from the time derivatives of the NSW basis vectors and is purely kinematic; it needs no gravitational parameter. Passing a Sun state with zero velocity gives the fixed-Sun approximation, which omits a term of order 2e-7 rad/s for an Earth orbit.

Parameters:

Name Type Description Default
x_eci ndarray or list

6D state vector in the ECI frame [x, y, z, vx, vy, vz] (m, m/s), shape (6,), or a batch of vectors with the 6 components along axis (for example shape (n, 6)).

required
x_sun ndarray or list

6D state vector of the Sun relative to the same center [x, y, z, vx, vy, vz] (m, m/s), shape (6,), or a batch of vectors with the 6 components along axis.

required
axis int

The axis along which the 6 components of a single vector lie; the remaining axes enumerate the batch. For a batch of shape (n, 6) the components lie along the last axis, so the default -1 applies; a (6, n) column layout uses axis=0. A single vector in one argument is broadcast across a batch in the other.

-1

Returns:

Type Description
ndarray

numpy.ndarray: Angular velocity of the NSW frame relative to ECI, expressed in NSW axes (rad/s), shape (3,), or the batch dimensions with 3 components along axis for batched input.

Example
1
2
3
4
5
6
7
import brahe as bh
import numpy as np

oe = np.array([bh.R_EARTH + 700e3, 0.01, 97.8, 15.0, 30.0, 45.0])
x_eci = bh.state_koe_to_eci(oe, bh.AngleFormat.DEGREES)
x_sun = np.array([bh.AU, 0.0, 0.0, 0.0, 0.0, 0.0])
omega = bh.omega_nsw(x_eci, x_sun)

state_eci_to_nsw builtin

state_eci_to_nsw(x_chief: Union[ndarray, Sequence], x_deputy: Union[ndarray, Sequence], x_sun: Union[ndarray, Sequence], axis: int = -1) -> ndarray

Transforms the absolute states of a chief and deputy satellite from the Earth-Centered Inertial (ECI) frame to the relative state of the deputy with respect to the chief in the rotating Nadir, Sun, Normal (NSW) frame.

Parameters:

Name Type Description Default
x_chief ndarray or list

6D state vector of the chief satellite in the ECI frame [x, y, z, vx, vy, vz] (m, m/s), shape (6,), or a batch of vectors with the 6 components along axis (for example shape (n, 6)).

required
x_deputy ndarray or list

6D state vector of the deputy satellite in the ECI frame [x, y, z, vx, vy, vz] (m, m/s), shape (6,), or a batch of vectors with the 6 components along axis (for example shape (n, 6)).

required
x_sun ndarray or list

6D state vector of the Sun relative to the same center [x, y, z, vx, vy, vz] (m, m/s), shape (6,), or a batch of vectors with the 6 components along axis.

required
axis int

The axis along which the 6 components of a single vector lie; the remaining axes enumerate the batch. For a batch of shape (n, 6) the components lie along the last axis, so the default -1 applies; a (6, n) column layout uses axis=0. A single vector in one argument is broadcast across a batch in the others.

-1

Returns:

Type Description
ndarray

numpy.ndarray: 6D relative state of the deputy with respect to the chief in the NSW frame [rho_X, rho_Y, rho_Z, rho_dot_X, rho_dot_Y, rho_dot_Z] (m, m/s), shape (6,), or the layout of the batched argument for batched input.

Example
import brahe as bh
import numpy as np

oe_chief = np.array([bh.R_EARTH + 700e3, 0.001, 97.8, 15.0, 30.0, 45.0])
oe_deputy = np.array([bh.R_EARTH + 701e3, 0.0015, 97.85, 15.05, 30.05, 45.05])

x_chief = bh.state_koe_to_eci(oe_chief, bh.AngleFormat.DEGREES)
x_deputy = bh.state_koe_to_eci(oe_deputy, bh.AngleFormat.DEGREES)
x_sun = np.array([bh.AU, 0.0, 0.0, 0.0, 0.0, 0.0])

x_rel_nsw = bh.state_eci_to_nsw(x_chief, x_deputy, x_sun)
print(f"Relative state in NSW: {x_rel_nsw}")

state_nsw_to_eci builtin

state_nsw_to_eci(x_chief: Union[ndarray, Sequence], x_rel_nsw: Union[ndarray, Sequence], x_sun: Union[ndarray, Sequence], axis: int = -1) -> ndarray

Transforms the relative state of a deputy satellite with respect to a chief satellite from the rotating Nadir, Sun, Normal (NSW) frame to the absolute state of the deputy in the Earth-Centered Inertial (ECI) frame.

Parameters:

Name Type Description Default
x_chief ndarray or list

6D state vector of the chief satellite in the ECI frame [x, y, z, vx, vy, vz] (m, m/s), shape (6,), or a batch of vectors with the 6 components along axis (for example shape (n, 6)).

required
x_rel_nsw ndarray or list

6D relative state of the deputy with respect to the chief in the NSW frame [rho_X, rho_Y, rho_Z, rho_dot_X, rho_dot_Y, rho_dot_Z] (m, m/s), shape (6,), or a batch of vectors with the 6 components along axis (for example shape (n, 6)).

required
x_sun ndarray or list

6D state vector of the Sun relative to the same center [x, y, z, vx, vy, vz] (m, m/s), shape (6,), or a batch of vectors with the 6 components along axis.

required
axis int

The axis along which the 6 components of a single vector lie; the remaining axes enumerate the batch. For a batch of shape (n, 6) the components lie along the last axis, so the default -1 applies; a (6, n) column layout uses axis=0. A single vector in one argument is broadcast across a batch in the others.

-1

Returns:

Type Description
ndarray

numpy.ndarray: 6D state vector of the deputy satellite in the ECI frame [x, y, z, vx, vy, vz] (m, m/s), shape (6,), or the layout of the batched argument for batched input.

Example
import brahe as bh
import numpy as np

oe_chief = np.array([bh.R_EARTH + 700e3, 0.001, 97.8, 15.0, 30.0, 45.0])
x_chief = bh.state_koe_to_eci(oe_chief, bh.AngleFormat.DEGREES)
x_sun = np.array([bh.AU, 0.0, 0.0, 0.0, 0.0, 0.0])

x_rel_nsw = np.array([1000.0, 500.0, -300.0, 0.0, 0.0, 0.0])

x_deputy = bh.state_nsw_to_eci(x_chief, x_rel_nsw, x_sun)
print(f"Deputy state in ECI: {x_deputy}")

See Also