Coordinate transformations and reference frames
DRT 111 Applied Mathematics for Technology
Lesson
By the end of this module you will be able to
- Explain the NED, ENU and FRD body frames and why we convert between them
- Rotate a vector in two dimensions with a rotation matrix
- Write rotation matrices about the x, y and z axes and combine them into the Z-Y-X matrix from roll, pitch and yaw
- Explain the properties of rotation matrices and the gimbal-lock problem
- Convert latitude and longitude differences into approximate north and east distances
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.
| Frame | x axis | y axis | z axis | Used in |
|---|---|---|---|---|
| NED (local Earth) | North | East | Down | PX4, ArduPilot, flight texts |
| ENU (local Earth) | East | North | Up | ROS, many GIS tools |
| FRD (body) | Forward | Right | Down | IMU, attitude control |
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.
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:
- Its inverse equals its transpose, . Converting back from the Earth frame to the body frame is therefore easy: .
- Its determinant is 1.
- 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
- Write the ENU point in NED.
- Rotate anticlockwise by .
- A drone heads and flies forward at 8 m/s. What are and ?
- If rotates from body to Earth frame, which matrix converts back?
- At latitude , how far east is a longitude difference of ?
Answers
- and m/s (flying east)
- m
Key formulas
| 2D rotation | |
| Body velocity to N, E | |
| Z-Y-X matrix | |
| Rotation properties | |
| Coordinate difference to distance |
Key references
- Beard, R. W., & McLain, T. W. (2012). Small unmanned aircraft: Theory and practice. Princeton University Press.
- Diebel, J. (2006). Representing attitude: Euler angles, unit quaternions, and rotation vectors. Stanford University. link
- 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
- Groves, P. D. (2013). Principles of GNSS, inertial, and multisensor integrated navigation systems (2nd ed.). Artech House.
- PX4 Autopilot. PX4 user and developer guide. link
Further reading
Study the assigned knowledge units in advance, review media and take the module quiz
Vectors, matrices and coordinate transformations for aircraft
Map coordinates and heights
In class / field
Lecture, case discussion and in-class problem solving
Learning evidence: Quiz results and submitted exercises