Coordinate Transformations

Direction Cosine Matrices

This function converts Euler Angle into Direction Cosine Matrix (DCM). The DCM is described by three sucessive rotation rotAngle1, rotAngle2, and rotAngle3 about the axis described by the rotation_sequence.

The default rotation_sequence=’ZYX’ is the aerospace sequence and rotAngle1 is the yaw angle, rotAngle2 is the pitch angle, and rotAngle3 is the roll angle. In this case DCM transforms a vector from the locally level coordinate frame (i.e. the NED frame) to the body frame.

This function can batch process a series of rotations (e.g., time series of Euler angles).

Parameters:

rotAngle1, rotAngle2, rotAngle3 : angles {(N,), (N,1), or (1,N)}

They are a sequence of angles about successive axes described by rotation_sequence.

input_unit : {‘rad’, ‘deg’}, optional

Rotation angles. Default is ‘rad’.

rotation_sequence : {‘ZYX’}, optional

Rotation sequences. Default is ‘ZYX’.

output_type : {‘ndarray’,’matrix’}, optional

Output type. Default is ‘ndarray’.

Returns:

C : {3x3} Direction Cosine Matrix

Notes

Programmer: Adhika Lie Created: May 03, 2011 Last Modified: January 12, 2016

This function converts a Direction Cosine Matrix (DCM) into the three rotation angles. The DCM is described by three sucessive rotation rotAngle1, rotAngle2, and rotAngle3 about the axis described by the rotation_sequence.

The default rotation_sequence=’ZYX’ is the aerospace sequence and rotAngle1 is the yaw angle, rotAngle2 is the pitch angle, and rotAngle3 is the roll angle. In this case DCM transforms a vector from the locally level coordinate frame (i.e. the NED frame) to the body frame.

This function can batch process a series of rotations (e.g., time series of direction cosine matrices).

Parameters:

C : {(3,3), (N,3,3), or (3,3,N)}

direction consine matrix that rotates the vector from the first frame to the second frame according to the specified rotation_sequence.

output_unit : {‘rad’, ‘deg’}, optional

Rotation angles. Default is ‘rad’.

rotation_sequence : {‘ZYX’}, optional

Rotation sequences. Default is ‘ZYX’.

Returns:

rotAngle1, rotAngle2, rotAngle3 : angles

They are a sequence of angles about successive axes described by rotation_sequence.

Notes

The returned rotAngle1 and 3 will be between +/- 180 deg (+/- pi rad). In contrast, rotAngle2 will be in the interval +/- 90 deg (+/- pi/2 rad).

In the ‘ZYX’ or ‘321’ aerospace sequence, that means the pitch angle returned will always be inside the closed interval +/- 90 deg (+/- pi/2 rad). Applications where pitch angles near or larger than 90 degrees in magnitude are expected should used alternate attitude parameterizations like quaternions.

ECEF and NED

Transform a vector resolved in ECEF coordinate to its resolution in the NED coordinate. The center of the NED coordiante is given by lat_ref, lon_ref, and alt_ref.

Parameters:

ecef : {(N,3)} input vector expressed in the ECEF frame

lat_ref : Reference latitude, unit specified by latlon_unit, default in deg

lon_ref : Reference longitude, unit specified by latlon_unit, default in deg

alt : Reference altitude, unit specified by alt_unit, default in m

Returns:

ned : {(N,3)} array like ecef position, unit is the same as alt_unit

Examples

>>> import numpy as np
>>> from navpy import ecef2ned
>>> lat 

Transform a vector resolved in NED (origin given by lat_ref, lon_ref, and alt_ref) coordinates to its ECEF representation.

Parameters:

ned : {(N,3)} input array, units of meters

lat_ref : Reference latitude, unit specified by latlon_unit, default in deg

lon_ref : Reference longitude, unit specified by latlon_unit, default in deg

alt_ref : Reference altitude, unit specified by alt_unit, default in m

Returns:

ecef : {(N,3)} array like ned vector, in the ECEF frame, units of meters

Notes

The NED vector is treated as a relative vector, and hence the ECEF representation returned is NOT converted into an absolute coordinate. This means that the magnitude of ned and ecef will be the same (bar numerical differences).

Examples

>>> import navpy
>>> ned = [0, 0, 1]
>>> lat_ref, lon_ref, alt_ref = 45.0, -93.0, 250.0 # deg, meters
>>> ecef = navpy.ned2ecef(ned, lat_ref, lon_ref, alt_ref)
>>> print("NED:", ned)
>>> print("ECEF:", ecef)
>>> print("Notice that 'down' is not same as 'ecef-z' coordinate.")

ECEF and LLA

Calculate the Latitude, Longitude and Altitude of a point located on earth given the ECEF Coordinates.

Parameters:

ecef : {(N,3)} array like input of ECEF coordinate in X, Y, and Z column, unit is meters

latlon_unit : {(‘deg’,’rad’)} specifies the output latitude and longitude unit

Returns:

lat : {(N,)} array like latitude in unit specified by latlon_unit

lon : {(N,)} array like longitude in unit specified by latlon_unit

alt : {(N,)} array like altitude in meters

References

[R1]Jekeli, C.,”Inertial Navigation Systems With Geodetic Applications”, Walter de Gruyter, New York, 2001, pp. 24

Convert Latitude, Longitude, Altitude, to ECEF position

Parameters:

lat : {(N,)} array like latitude, unit specified by latlon_unit, default in deg

lon : {(N,)} array like longitude, unit specified by latlon_unit, default in deg

alt : {(N,)} array like altitude, unit specified by alt_unit, default in m

Returns:

ecef : {(N,3)} array like ecef position, unit is the same as alt_unit

Convert Latitude, Longitude, Altitude to its resolution in the NED coordinate. The center of the NED coordiante is given by lat_ref, lon_ref, and alt_ref.

For example, this can be used to convert GPS data to a local NED frame.

Parameters:

lat : {(N,)} array like latitude, unit specified by latlon_unit, default in deg

lon : {(N,)} array like longitude, unit specified by latlon_unit, default in deg

alt : {(N,)} array like altitude, unit specified by alt_unit, default in m

lat_ref : Reference latitude, unit specified by latlon_unit, default in deg

lon_ref : Reference longitude, unit specified by latlon_unit, default in deg

alt : Reference altitude, unit specified by alt_unit, default in m

Returns:

ned : {(N,3)} array like ecef position, unit is the same as alt_unit

NED and LLA

Calculate the Latitude, Longitude and Altitude of points given by NED coordinates where NED origin given by lat_ref, lon_ref, and alt_ref.

Parameters:

ned : {(N,3)} array like input of NED coordinate in N, E, and D column, unit is meters

lat_ref : Reference latitude, unit specified by latlon_unit, default in deg

lon_ref : Reference longitude, unit specified by latlon_unit, default in deg

alt_ref : Reference altitude, unit specified by alt_unit, default in m

latlon_unit : {(‘deg’,’rad’)} specifies the output latitude and longitude unit

Returns:

lat : {(N,)} array like latitude in unit specified by latlon_unit

lon : {(N,)} array like longitude in unit specified by latlon_unit

alt : {(N,)} array like altitude in meters

navpy.lla2ned(lat, lon, alt, lat_ref, lon_ref, alt_ref, latlon_unit='deg', alt_unit='m', model='wgs84')

Convert Latitude, Longitude, Altitude to its resolution in the NED coordinate. The center of the NED coordiante is given by lat_ref, lon_ref, and alt_ref.

For example, this can be used to convert GPS data to a local NED frame.

Parameters:

lat : {(N,)} array like latitude, unit specified by latlon_unit, default in deg

lon : {(N,)} array like longitude, unit specified by latlon_unit, default in deg

alt : {(N,)} array like altitude, unit specified by alt_unit, default in m

lat_ref : Reference latitude, unit specified by latlon_unit, default in deg

lon_ref : Reference longitude, unit specified by latlon_unit, default in deg

alt : Reference altitude, unit specified by alt_unit, default in m

Returns:

ned : {(N,3)} array like ecef position, unit is the same as alt_unit