## Orientation, Position, and Coordinate Convention

The Navigation Toolbox™ enables you to track orientation, position, pose, and trajectory of a platform.
A *platform* refers generally to any object you want to track its
state.

### Orientation

*Orientation* is defined by angular displacement. Orientation can
be described in terms of point or frame rotation. In point rotation, the coordinate system
is static and the point moves. In frame rotation, the point is static and the coordinate
system moves. For a given axis and angle of rotation, point rotation and frame rotation
define equivalent angular displacement but in opposite directions.

Navigation Toolbox defaults to frame rotation.

In frame representation, orientation is defined as rotation that takes the parent frame to the child frame. The choice of parent and child frames depends on the problem being solved. For example, when you manipulate the mounting of a sensor on a platform, you can select the platform body frame as the parent frame and select the sensor mounting frame as the child frame. The rotation from the platform body frame to the sensor mounting frame defines the orientation of the sensor with respect to the platform.

Navigation Toolbox primarily supports the NED (north-east-down) coordinate frame. You can also use the ENU (east-north-up) coordinate frame in many features.

### Frame Rotation

To relate one orientation to another you must rotate a frame. The table summarizes the
z-y-x rotation conventions. You can also use other conventions, such as the z-x-z rotation
convention. See the rotation sequence (`RS`

) argument of `quaternion`

for more
details on these conventions.

Variable | Euler Angle | Symbol | Output Interval (Degrees) |
---|---|---|---|

z | Yaw | ψ | −180 ≤ ψ < 180 |

y | Pitch | θ | −90 ≤ θ ≤ 90 |

x | Roll | ϕ | −180 ≤ ϕ < 180 |

A positive rotation angle corresponds to a clockwise rotation about an axis when viewing from the origin along the positive direction of the axis. The right-hand convention is equivalent, where positive rotation is indicated by the direction in which the fingers on your right hand curl when your thumb is pointing in the direction of the axis of rotation.

To define three-dimensional frame rotation, you must rotate sequentially about the axes. Navigation Toolbox uses intrinsic (carried frame) rotation, in which, after each rotation, the axis is updated before the next rotation. For example, to rotate an axis using the z-y-x convention:

Rotate the parent frame about the

*z*-axis to yield a new set of axes, (*x'*,*y'*,*z*), where the*x*- and*y*-axes have changed to*x*'- and*y*'-axes and the*z*-axis remains unchanged.$$\left[\begin{array}{c}{x}^{\text{'}}\\ {y}^{\text{'}}\\ z\end{array}\right]={\text{R}}_{z}\left(\psi \right)\left[\begin{array}{c}x\\ y\\ z\end{array}\right]$$

Rotate the new set of axes about the

*y*'-axis, yielding another new set of axes, (*x*'',*y*',*z*').$$\left[\begin{array}{c}{x}^{\text{'}\text{'}}\\ {y}^{\text{'}}\\ {z}^{\text{'}}\end{array}\right]={\text{R}}_{y}\left(\theta \right)\left[\begin{array}{c}{x}^{\text{'}}\\ {y}^{\text{'}}\\ z\end{array}\right]$$

Rotate this new set of axes about the

*x*''-axis, arriving at the desired child frame, (*x*'',*y*'',*z*'').$$\left[\begin{array}{c}{x}^{\text{'}\text{'}}\\ {y}^{\text{'}\text{'}}\\ {z}^{\text{'}\text{'}}\end{array}\right]={\text{R}}_{x}\left(\varphi \right)\left[\begin{array}{c}{x}^{\text{'}\text{'}}\\ {y}^{\text{'}}\\ {z}^{\text{'}}\end{array}\right]$$

This sequence of rotations follows the convention outlined in Rotations, Orientation, and Quaternions. The rotation matrix required to convert a vector in the parent frame to a vector in the child frame for a given yaw, pitch, and roll is computed as:

$$\text{R}\left(\psi ,\theta ,\varphi \right)={\text{R}}_{x}\left(\varphi \right){\text{R}}_{y}\left(\theta \right){\text{R}}_{z}\left(\psi \right)=\left[\begin{array}{ccc}\mathrm{cos}\psi \mathrm{cos}\theta & \mathrm{sin}\psi \mathrm{cos}\theta & -\mathrm{sin}\theta \\ \mathrm{cos}\psi \mathrm{sin}\theta \mathrm{sin}\varphi -\mathrm{sin}\psi \mathrm{cos}\varphi \text{\hspace{1em}}& \mathrm{sin}\psi \mathrm{sin}\theta \mathrm{sin}\varphi +\mathrm{cos}\psi \mathrm{cos}\varphi \text{\hspace{1em}}& \mathrm{cos}\theta \mathrm{sin}\varphi \\ \mathrm{cos}\psi \mathrm{sin}\theta \mathrm{cos}\varphi +\mathrm{sin}\psi \mathrm{sin}\varphi \text{\hspace{1em}}& \mathrm{sin}\psi \mathrm{sin}\theta \mathrm{cos}\varphi -\mathrm{cos}\psi \mathrm{sin}\varphi \text{\hspace{1em}}& \mathrm{cos}\theta \mathrm{cos}\varphi \end{array}\right]$$

For features that support frame-based processing, Navigation Toolbox provides coordinates as an *N*-by-3 matrix, where
*N* is the number of samples in time and the three columns correspond to
the *x*-, *y*-, and *z*-axes. The
following calculation rotates a parent frame to a child frame:

$${a}_{\text{child}}={\left(\text{R}\left(\psi ,\theta ,\varphi \right)\times {\left({a}_{\text{parent}}\right)}^{\text{T}}\right)}^{\text{T}}$$

where *a*_{parent} represents a
*N*-by-3 matrix of coordinates expressed in the parent coordinate frame
and *a*_{child} is the resulting
*N*-by-3 matrix of coordinates expressed in the child frame.

Navigation Toolbox enables efficient orientation computation using the `quaternion`

data type.
To create a rotation matrix using quaternions, use the `rotmat`

function.

#### Express Gravitational Vector in Body Frame

In an NED frame, the gravitational vector can be express as

`gNED = [0 0 9.8]; % m/s^2`

Consider a body frame obtained by a consecutive rotation of 20 degrees in yaw, 5 degrees in pitch, and 10 degrees in roll from the parent NED frame.

yaw = 20; % degree pitch = 5; % degree roll = 10; % degree

To obtain the expression of the gravitational vector in the body frame, you first obtain the `quaternion`

corresponding to the three consecutive Euler angles.

q = quaternion([yaw pitch roll],"eulerd","zyx","frame");

Then, using the `rotateframe`

object function, you can obtain the coordinates of the gravitational vector in the body frame as

gBody = rotateframe(q,gNED)

`gBody = `*1×3*
-0.8541 1.6953 9.6144

Alternately, you can obtain the coordinates using rotation matrix. First, you use the `rotmat`

object function of `quaternion`

to obtain the corresponding rotation matrix that transforms coordinates from the NED frame to the body frame.

`R = rotmat(q,"frame");`

Then, obtain the coordinates of the gravitational vector in the body frame as

gBody2 = (R*gNED')'

`gBody2 = `*1×3*
-0.8541 1.6953 9.6144

### Position

*Position* is defined as the translational distance from a parent
frame origin to a child frame origin. For example, take the local NED coordinate system as
the parent frame. In the NED coordinate system:

The origin is arbitrarily fixed to a point on the surface of the Earth. This makes the NED coordinate system

*local*.The

*x*-axis points toward the ellipsoid north.The

*y*-axis points toward the ellipsoid east.The

*z*-axis points downward along the ellipsoid normal (geodetic latitude,*ρ*).

#### Azimuth and Elevation

Given a vector in **R**^{3}:

*Azimuth*is defined as the angle from the*x*-axis to the orthogonal projection of the vector onto the*xy*-plane. The angle is positive going from the*x*-axis toward the*y*-axis. Azimuth is given in degrees in the range [−180, 180).*Elevation*is defined as the angle from the projection onto the*xy*-plane to the vector. The angle is positive going from the*xy*-plane to the*z*-axis. Elevation is given in degrees in the range [−90, 90].

### Pose and Trajectory

To specify an object in 3-D space fully, you can combine position and orientation.
*Pose* is defined as the combination of position and orientation.
*Trajectory* defines how pose changes over time. To generate
ground-truth trajectories in Navigation Toolbox, use `kinematicTrajectory`

or `waypointTrajectory`

.

## See Also

`quaternion`

| `transformMotion`

| Rotations, Orientation, and
Quaternions

## References

[1] IEEE. Standard for Distributed Interactive Simulation – Application Protocols. IEEE P1278.1/D16, Rev 18, May 2012.