เวกเตอร์ เมทริกซ์ และการแปลงพิกัดสำหรับอากาศยาน

Vectors, dot/cross products, rotation matrices and transformations between body and earth frames

Last updated:

Why it matters

Many drone quantities have both size and direction: velocity, wind, thrust, the position of a target. These are vectors. The difficulty is that each sensor reports vectors in a different frame. The camera sees a target in the drone's own frame, but the map needs it in the earth frame. The IMU measures acceleration in the body frame, but the position controller works in the earth frame. The tool that moves vectors between frames is the rotation matrix. This page covers vectors, dot and cross products and rotation matrices, using NED (north, east, down) for the earth and FRD (forward, right, down) for the body.

Vectors and vector addition

A 3-D vector is written as three components, such as v = (vN, vE, vD). Its magnitude is |v| = √(vN2 + vE2 + vD2). A scalar has size only, such as mass, temperature or energy. Vectors add component by component, and only when both are in the same frame.

The everyday example is the wind triangle: ground velocity = air velocity + wind velocity. Assume a drone heading east at 15 m/s airspeed with wind blowing towards the south at 8 m/s. In 2-D NED, air velocity is (0, 15) and wind is (−8, 0). Ground velocity is (−8, 15), with magnitude √(82 + 152) = 17 m/s and track atan2(15, −8) ≈ 118.1 degrees. The nose points at 90 degrees, but the drone moves along 118.1 degrees. To actually travel east it must point partly into the wind, towards the north.

Dot and cross products

The dot product of a and b is a·b = a1b1 + a2b2 + a3b3 = |a||b| cos θ. The result is a scalar. It gives the angle between vectors, or how much of one vector lies along another direction. A dot product of zero means the vectors are perpendicular.

In the wind example, the angle between the heading (0, 15) and the track (−8, 15) follows from cos θ = (0 × (−8) + 15 × 15)/(15 × 17) = 225/255 ≈ 0.882, so θ ≈ 28.1 degrees. This is the drift angle, which matters to aerial photographers because images are rotated relative to the flight line.

The cross product a × b is a vector perpendicular to both, of magnitude |a||b| sin θ, with direction given by the right-hand rule. In drones it gives torque, τ = r × F, where r is the point of application relative to the centre of gravity. In FRD, a front motor at r = (0.25, 0, 0) m producing 10 N of upward thrust has F = (0, 0, −10) N, because z points down. The cross product is τ = (0, 2.5, 0) N·m, a positive moment about y, which is nose up. A right-side motor at r = (0, 0.25, 0) m gives τ = (−2.5, 0, 0) N·m, negative roll, right side rising, as intuition says.

Rotation matrices

A matrix is a table of numbers that turns one vector into another when multiplied. A 3×3 rotation matrix R re-expresses a vector's components from one frame in another without changing its length. A rotation about z by the yaw angle ψ is:

Rz(ψ) = [[cos ψ, −sin ψ, 0], [sin ψ, cos ψ, 0], [0, 0, 1]]

The earth-frame vector is vNED = R vbody. For a general attitude, the full matrix is the product of three rotations in ZYX order, R = Rz(ψ) Ry(θ) Rx(φ). The order matters because matrix multiplication does not commute.

Rotation matrices have two key properties. First, they are orthonormal: RTR = I, where I is the identity matrix and RT is the transpose (rows and columns swapped). The reverse conversion is therefore simply vbody = RT vNED, with no general inverse needed. Second, the determinant is +1. A value of −1 means an axis has been reflected, usually from mixing right-handed and left-handed frames.

To rotate and translate together, for example from the camera frame to the map frame, use a homogeneous transform, which packs R and the translation vector into one 4×4 matrix. Chains of frames are then handled by multiplying the matrices in order.

Worked example: locating a target seen by the camera

Assume the drone hovers level (roll = pitch = 0) at NED (100, 50, −30) m, that is 30 m up, with yaw ψ = 30 degrees. The detector reports a target 10 m ahead and 2 m to the right in the drone's horizontal plane, pbody = (10, 2, 0) m.

  1. cos 30° ≈ 0.8660 and sin 30° = 0.5.
  2. North component: 0.8660 × 10 − 0.5 × 2 ≈ 7.660 m.
  3. East component: 0.5 × 10 + 0.8660 × 2 ≈ 6.732 m.
  4. Adding the drone position gives the target at NED ≈ (107.66, 56.73, −30) m.

Sanity check: the length of (10, 2) is √104 ≈ 10.20 m, and so is the length of (7.660, 6.732). Rotation does not change distance. For the reverse direction, a 10 m/s wind blowing north, (10, 0, 0) in the earth frame, multiplied by RT gives (8.66, −5, 0) in the body frame: 8.66 m/s towards the nose and 5 m/s towards the left.

When the drone is tilted, the full matrix including roll and pitch is needed. With the nose 10 degrees down (pitch = −10 degrees) and 20 N of total thrust, the body-frame thrust (0, 0, −20) becomes about (3.47, 0, −19.70) N in the earth frame: 3.47 N pulling forward and 19.70 N lifting.

Common pitfalls

  • Adding vectors from different frames. Convert to a common frame first.
  • Using R where RT is needed, or the reverse. Names that state the direction, such as R_ned_from_body, prevent this.
  • Multiplying in the wrong order. RzRy is not RyRz.
  • Forgetting that z points down in NED and FRD, so upward thrust has a negative z component.
  • Swapping cross-product operands. r × F = −(F × r), so the torque direction flips.
  • Not checking RTR = I after building a matrix in code. The check catches sign typos immediately.

Continue in the lessons

Key references

  1. Stroud, K. A., & Booth, D. J. (2020). Engineering mathematics (8th ed.). Bloomsbury.
  2. Beard, R. W., & McLain, T. W. (2012). Small unmanned aircraft: Theory and practice. Princeton University Press. link
  3. Strang, G. (2016). Introduction to linear algebra (5th ed.). Wellesley-Cambridge Press. link
  4. Diebel, J. (2006). Representing attitude: Euler angles, unit quaternions, and rotation vectors. Stanford University. link

Used in courses

How to cite this page

Drone Institute, Rangsit University. (2026). เวกเตอร์ เมทริกซ์ และการแปลงพิกัดสำหรับอากาศยาน. In UAS Technology Knowledge Hub (B.Tech.). https://rsu-uat.pk-research.work/en/kb/new/math-vectors-matrices/