Sitemap
Henry Odoemelem

Henry Odoemelem

Firmware engineer writing on embedded systems. YouTube: https://www.youtube.com/@huobuilds

How Does a Drone Know Where It Is Pointing?

3 min readJul 31, 2026

Every robot lives in two worlds at once:

The world frame and its own body frame.

A robotic arm knows where its joints are relative to itself. But when you ask it to reach for an object on a table, it must answer a harder question:

Where is that object in the world based on what the camera sees?

This problem appears throughout robotics.

The solution is a rotation matrix.

Press enter or click to view image in full size
A drone uses both the world-fixed NED frame and its own body-fixed frame.

A rotation matrix is the bridge between two coordinate frames.

You build one by asking a simple question:

My axes point somewhere in the world. How can I describe them using the world’s axes?

The answer comes from basic trigonometry.

Start with the drone’s forward axis. This is a unit vector with a length of one. After the drone rotates through a yaw angle, its forward direction can be broken into North and East components using sine and cosine.

Press enter or click to view image in full size
Resolving the drone’s forward axis into North and East components.

The same process gives us the drone’s right-side axis. Its direction also depends on the yaw angle, but one component points in the negative North direction.

Press enter or click to view image in full size
Deriving the drone’s right-side unit vector using basic trigonometry.

During a pure yaw rotation, the drone spins around its vertical axis. The down axis does not change.

Press enter or click to view image in full size
The down axis remains unchanged during yaw rotation.

Each body axis is now expressed as a unit vector in the world frame.

Get Henry Odoemelem’s stories in your inbox

Join Medium for free to get updates from this writer.

Stack the three vectors as rows, and the result is the yaw rotation matrix.

Press enter or click to view image in full size
Stacking the three unit vectors produces the yaw rotation matrix.

Now apply the same idea to pitch and roll.

When a quadcopter rotates, its sensors still measure acceleration and angular velocity in the drone’s body frame. However, attitude estimation and navigation often require those measurements to be understood relative to the world.

So we build one rotation matrix for yaw, one for pitch, and one for roll.

Multiply the three matrices together, and the result is a compact 3 × 3 matrix that represents the drone’s complete attitude.

Press enter or click to view image in full size
Combining roll, pitch, and yaw produces the complete rotation matrix from the NED frame to the drone’s body frame.

This same principle is used in drones, robotic arms, aircraft, satellites, autonomous vehicles, and many other systems.

The mathematics may look complex at first, but the foundation is simple:

  1. Represent each axis as a unit vector.
  2. Resolve it into components using sine and cosine.
  3. Stack the vectors into a matrix.
  4. Use the matrix to transform measurements between coordinate frames.

That is where the rotation matrix comes from.

In the QuadFS drone flight controller firmware, this is more than a mathematical exercise. I designed the firmware to use the rotation matrix as part of the attitude-estimation system, allowing the flight controller to determine the drone’s orientation and correctly transform sensor measurements between the body and world frames.

To see how these concepts are implemented in a complete STM32 drone flight controller, follow the free drone build course on YouTube:

https://www.youtube.com/@huobuilds

The firmware, complete course guide, schematics, research materials, and supporting resources are available on Notion.

--

--

Henry Odoemelem
Henry Odoemelem

Written by Henry Odoemelem

Firmware engineer writing on embedded systems. YouTube: https://www.youtube.com/@huobuilds