Module 4/5 · Weeks 10–12 · 27 h

Coordinate transformations and reference frames

DRT 111 Applied Mathematics for Technology

About 90 minDraft, awaiting reviewLast updated 26 September 2026

Lesson

By the end of this module you will be able to

  1. Explain the NED, ENU and FRD body frames and why we convert between them
  2. Rotate a vector in two dimensions with a rotation matrix
  3. Write rotation matrices about the x, y and z axes and combine them into the Z-Y-X matrix from roll, pitch and yaw
  4. Explain the properties of rotation matrices and the gimbal-lock problem
  5. Convert latitude and longitude differences into approximate north and east distances

Prerequisites: DRT 111 Modules 2 and 3 (trigonometry, vectors and matrix multiplication)

Why we need several frames

Imagine giving directions to a friend. If you do not know which way they are facing, “turn right” and “go east” may mean the same direction or different ones.

A drone faces this problem constantly. The IMU and camera are fixed to the airframe, so they measure relative to the drone, but a mission defines positions relative to the Earth. The autopilot converts between frames dozens of times per second. The tool it uses is the rotation matrix, which builds on the matrices of Module 3.

Common reference frames

A reference frame is a set of three perpendicular axes with a defined origin and orientation. Three frames are used often in drone work.

Framex axisy axisz axisUsed in
NED (local Earth)NorthEastDownPX4, ArduPilot, flight texts
ENU (local Earth)EastNorthUpROS, many GIS tools
FRD (body)ForwardRightDownIMU, attitude control
Left: NED frame with north pointing up and east to the right. Right: FRD frame fixed to a drone whose nose is turned from north by angle psi
Figure 1. The NED Earth frame and the FRD body frame, viewed from above

All three are right-handed: curl the fingers of your right hand from the x axis to the y axis and your thumb points along z. Converting between ENU and NED is simple: swap north and east, then flip the sign of the vertical axis.

Watch out

A very common bug when connecting ROS to an autopilot is forgetting the ENU–NED conversion, so the drone flies the wrong way or descends instead of climbing. Always check which frame each piece of software uses.

Rotation in two dimensions

Start with the simple case. Rotating a vector anticlockwise by angle gives

For example, rotating by gives . Its length is still 10: rotation changes direction, not size.

Applying it to heading

When a drone’s nose points at yaw angle from north and it moves with body velocities (forward) and (right), its Earth-frame velocity is

Example 1. From body frame to Earth frame

A drone heads and flies forward at 10 m/s (, ).

  • m/s
  • m/s

So the drone moves north at 5 m/s and east at 8.66 m/s.

Rotation in three dimensions

An aircraft’s attitude in 3D is described by three Euler angles:

  • Roll (): rotation about the forward axis, banking the wings
  • Pitch (): rotation about the right axis, raising or lowering the nose
  • Yaw (): rotation about the down axis, turning the nose left or right

Each single-axis rotation has its own matrix:

The Z-Y-X sequence

Because matrix multiplication is not commutative, the order of rotation matters. The aviation standard is the Z-Y-X sequence: starting from the Earth frame, apply yaw, then pitch about the new axis, then roll about the newest axis.

Three steps: rotate about the down axis by yaw, then about the new right axis by pitch, then about the new forward axis by roll
Figure 2. The Z-Y-X rotation sequence

The matrix that converts a vector from the body frame to the NED frame is

where and . You do not need to memorise this matrix, but you should understand that it comes from multiplying three matrices in order.

Try it

Open the 3D models page, model 2. Adjust roll, pitch and yaw and watch the drone’s axes turn relative to the Earth frame. The matrix below the model is computed from the formula above in real time. Set roll = 0 and pitch = 0 and change only yaw: the matrix reduces to the 2D rotation form.

Properties of rotation matrices

Every rotation matrix has three important properties:

  1. Its inverse equals its transpose, . Converting back from the Earth frame to the body frame is therefore easy: .
  2. Its determinant is 1.
  3. It preserves vector length, changing only direction.

Gimbal lock

As pitch approaches , the roll and yaw axes line up and Euler angles can no longer tell the two rotations apart. This is gimbal lock. Real autopilots therefore store attitude internally as quaternions, which do not have this problem, and convert to Euler angles only for display. You will study this further in DRT 335.

Latitude, longitude and distance on Earth

GNSS reports position as latitude (), longitude () and height above the ellipsoid () in WGS 84, which models the Earth as an ellipsoid with equatorial radius m and inverse flattening .

For short distances of up to a few kilometres, we can treat the Earth as a sphere of radius m and convert angle differences (in radians) into distances:

The factor is needed for east distances because lines of longitude converge towards the poles.

Example 2. How far is 0.001 degrees near Rangsit?

Rangsit University lies at about N.

  • rad
  • m
  • m

These figures make quick sanity checks easy: waypoints that differ in the third decimal place of latitude are hundreds of metres apart.

Common mistakes

Watch out

  • Mixing NED and ENU. Check which frame each tool uses.
  • Multiplying rotations in the wrong order. Z-Y-X differs from X-Y-Z.
  • Using instead of when converting back.
  • Forgetting in east distances.
  • Using the spherical approximation over long distances. For tens of kilometres or more, use ellipsoidal formulas or a geospatial library.

Summary

  • Sensors measure in the body frame (FRD); navigation uses an Earth frame (NED or ENU), so rotation matrices convert between them.
  • ENU and NED differ by swapping north and east and flipping the vertical sign.
  • Attitude is given by roll, pitch and yaw, combined in the Z-Y-X order.
  • Rotation matrices satisfy and preserve length.
  • Gimbal lock occurs at pitch , so autopilots use quaternions internally.
  • Latitude and longitude differences convert approximately to distances with and .

Check your understanding

  1. Write the ENU point in NED.
  2. Rotate anticlockwise by .
  3. A drone heads and flies forward at 8 m/s. What are and ?
  4. If rotates from body to Earth frame, which matrix converts back?
  5. At latitude , how far east is a longitude difference of ?
Answers
  1. and m/s (flying east)
  2. m

Key formulas

2D rotation
Body velocity to N, E
Z-Y-X matrix
Rotation properties
Coordinate difference to distance

Key references

  1. Beard, R. W., & McLain, T. W. (2012). Small unmanned aircraft: Theory and practice. Princeton University Press.
  2. Diebel, J. (2006). Representing attitude: Euler angles, unit quaternions, and rotation vectors. Stanford University. link
  3. National Geospatial-Intelligence Agency. (2014). Department of Defense World Geodetic System 1984: Its definition and relationships with local geodetic systems (NGA.STND.0036_1.0.0_WGS84). link
  4. Groves, P. D. (2013). Principles of GNSS, inertial, and multisensor integrated navigation systems (2nd ed.). Artech House.
  5. PX4 Autopilot. PX4 user and developer guide. link

Further reading

Study the assigned knowledge units in advance, review media and take the module quiz

In class / field

Lecture, case discussion and in-class problem solving

Learning evidence: Quiz results and submitted exercises

Module quiz

This is a formative self-check, not a graded exam

Knowledge domain: Mathematics, physics and statistics · Control, autopilot and navigation · Surveying, mapping and geoinformatics