# Camera on Airplane: Extrinsic plus Intrinsic 3D Rotations?

Tags:
1. Sep 13, 2015

### rpmc

Apologies up front for the long question … I have tried to be brief.

I want to define camera angles for Google Earth (GE) when rotated about an aircraft yaw axis. The input is Latitude, Longitude, Altitude plus Heading, Pitch and Bank angles, actually coming from Flight Simulator. These drive the GE camera view which is similarly defined in terms of Latitude, Longitude, Altitude and Heading, Tilt and Roll angles, with the GE camera initially looking straight ahead, along the roll axis of the aircraft. As I understand it, these angles define an extrinsic rotation (is this correct?) relative to the world coordinate system, but at any rate, they are supplied by Flight Simulator. This part is working fine and I get a GE view the pilot would see looking straight ahead.

However, I want to be able to rotate the GE camera view around the aircraft yaw axis by some arbitrary angle, and derive new GE Heading, Tilt, and Roll angles that would replicate, for example, looking left instead of straight ahead. At any point in time, the aircraft can be turning or performing aerobatics including inverted flight, and I want the rotated GE Heading, Tilt, and Roll angles to capture the aircraft maneuvering. For example, an aircraft performing an inside loop looks like a left barrel roll to a camera pointing -90 degrees Yaw = left. As I understand the camera rotation, it is an intrinsic rotation relative to the current aircraft axis system. The answer I need, the rotated GE angles, must be stated relative to the world coordinate system.

Assumptions:

Aircraft Relative to World, right handed system
Roll axis = x, roll angle = u
Pitch axis = y, pitch angle = v
Yaw axis = z, yaw angle = w (positive Z = down)

Camera relative to Aircraft, right handed system
Roll axis = xx, roll angle = a
Pitch axis = yy, pitch angle = b
Yaw axis = zz, yaw angle = c (positive zz = belly of plane)

I understand the elemental rotation functions are:
Code (Text):

Rx(u)=      1        0        0
0      c(u)    -s(u)
0      s(u)     c(u)

Ry(v)=    c(v)       0      s(v)
0        1        0
-s(v)       0      c(v)

Rz(w)=    c(w)    -s(w)       0
s(w)     c(w)       0
0        0        1

and similar for the camera rotation about the airplane axis system.

What next? I think my first problem is to generate the correct full rotation matrix that is a product of the elemental extrinsic rotations of the aircraft times the product of the elemental intrinsic rotations of the camera. Is that correct? I believe I'm having difficulty keeping track of extrinsic vs. intrinsic and producing the final, full rotation matrix. And, I may indeed be wrong about the first rotation being extrinsic.

After that, the issue is to find the GE rotated Heading, Tilt and Roll angles that come out of the final full rotation matrix.

Any suggestions or links to references are most appreciated. I would like to accomplish this first using Euler (Tait-Bryan) rotations, and after I understand that, move on to Quaternions.

Robert

Last edited: Sep 14, 2015
2. Sep 14, 2015

### andrewkirk

There's probably a standard approach in graphics programming that is slicker than this, but this post explains how I'd approach it, from first principles.

I find it easier to work with vectors than with angles, because I'm more used to them. A rotation of a vector is achieved by pre-multiplying it by a rotation matrix.

To fully define the viewpoint direction of a camera or plane we need two vectors: one that points along the lens/fuselage and another, orthogonal to that, that points to the top of the camera/plane. Call these a 'point' vector and a 'top' vector' respectively.

We have two pairs: the point and top vectors of the plane, and of the camera.

Assume we have the point and top vectors of the plane, which are given by the Heading, Tilt and Roll angles in terms of world coordinates. The Heading and Tilt angles are the Azimuth and (90 degrees minus Zenith) angles of the point vector in spherical coordinates. The Roll angle relates to the top vector

Assume we also have the Roll, Pitch and Yaw angles of the camera relative to the plane. These transformations are usually specified as intrinsic rotations, which means they are specified in coordinate systems that have ben transformed by any preceding rotations. The order of application matters, so we'll assume the order is roll first, then pitch, then yaw. It is more convenient to calculate with extrinsic rotations, which means they are specified using untransformed coordinate systems. Fortunately, to convert from intrinsic to extrinsic, all we need to do is reverse the order of application, so What is needed is to calculate:

$$\vec{Point}_{Camera}=Roll^{Cam}_{Plane} \times Pitch^{Cam}_{Plane}\times Yaw^{Cam}_{Plane}\times \vec{Point}_{Plane}$$

where the first three factors are (extrinsic) rotation matrices and the last is the plane's point vector.

Similarly

$$\vec{Top}_{Camera}=Roll^{Cam}_{Plane} \times Pitch^{Cam}_{Plane}\times Yaw^{Cam}_{Plane}\times \vec{Top}_{Plane}$$

If the plane point and top vectors are specified in world coordinates then so will the camera point and top vectors. You can then extract the camera's GE Heading, Tilt and Roll angles from those two vectors.

The Wikipedia article on Euler angles looks quite good. That probably tells how to do this interms of angles rather than vectors, but I didn't get time to dive into it.

3. Sep 17, 2015

### rpmc

Thanks Andre,

I think I understand the concept of your approach, vectors vs angles, but I'm still hung up on some points.

Do you have the time to expand a bit on "A rotation of a vector is achieved by pre-multiplying it by a rotation matrix"? I'd like to see the matrix math representation of that.

Thanks again for your quick response.

4. Sep 18, 2015

### andrewkirk

In your opening post you show the matrices for rotations about the x, y and z axes, by angles u, v, w respectively, as Rx(u), Ry(v), Rz(w) resp.

Say you have a vector $\vec{v}=\left(\array{1\\ 0\\ 2}\right)$ and you want to rotate it first by u around the x axis, then by v around the y axis, then by w around the z axis. Then the result will be the vector you get from the following matrix multiplication:

$$Rz(w)\times \left( Ry(v)\times \left(Rx(u)\times \vec{v}\right)\right)$$

The parentheses are not necessary, because matrix multiplication is associative, but I've put them in to show you the usual order of applying the transformations.

Those transformations are relative to fixed x,y,z axes. With your camera using a roll,pitch,yaw system, your 2nd and 3rd rotations would be specified relative to transformed axes, because each rotation transforms the coordinate axes used to specify the next rotation, as well as transforming the vector. Say you have chosen x,y and z to represent the roll, pitch and yaw axes. Then a bit of mathematical manipulation shows that there's an easy way to allow for the transformed axes. To give the above vector a roll of u followed by a pitch of v followed by a yaw of w, we simply reverse the order of matrix multiplication as follows:

$$Rx(u)\times \left( Ry(v)\times \left(Rz(w)\times \vec{v}\right)\right)$$