# Airplanes and Matrix Transformations

I’ve been busy (understatement of the year). I’ve been working on multiple projects (many of which will be highlighted here in the near future) and as the quarter is winding down, I figured I’d share some shorter ones I’ve worked on. This one is for a matrix class (essentially, the class focuses on the application of matrix theory- glorified linear algebra, if you will). The goal of this project was to construct a 3D object (an airplane) and perform various transforms on it. For all of the transformations that follow, green is the original aircraft while blue is the transformed version.

Now, let’s begin…

In order to perform matrix manipulations, three functions were created called **rotate_3D**, **translate_3D**, and **dilate_3D**. These functions, along with the script used to generate all of the following plots, can be found at the end of this document.

First, the aircraft shown in Figure 1 was dilated by 1.5. This was done by pre-multiplying the aircraft’s matrix (which can be a 3 x n sized matrix) by

This resulted in Figure 2 (note that for all ensuing graphs, the blue aircraft is the transformation while the green is the original, unmodified, aircraft (as shown in Figure 1).

Next, the aircraft was reflected about the Y axis as shown in Figure 3. This was done by pre-multiplying the aircraft’s matrix by

The aircraft then was rotated about the X axis by 60˚ (Figure 4). In order to perform a rotation in three-dimensional space, the following three matrices can be used:

Where α is the roll angle, β is the pitch angle and ɣ is the yaw angle. Thus, a rotation of 60˚ about the X axis can also be called a roll of 60˚. Figure 5 shows a Yaw of 45˚, Figure 6 shows a Pitch of 30˚ and Figure 7 shows a Roll of 30˚.

Figure 8 shows a translation by 10 units in the X direction, 10 units in the Y direction and 0 units in the Z direction followed by a rotation about the X-axis by 30˚ and finally a dilation of 2. The order was then changed to a rotation, translation and then dilation (all with the same parameters) which resulted in Figure 9. As one can see, the figures are clearly different. Mathematically, this makes sense and can be proven experimentally quite easily. Say we have a matrix

.

If we were to translate by 10 units in the X and Y direction and then rotate with a roll of 30˚ followed by a dilation of two, we would need to pre-multiply in the following order: Dilation*Rotation*Translation*A. Thus, we can first multiply our Dilation and Rotation matrices:

We can then take this matrix, which we’ll call C, and multiply it by our translation matrix T. However, in order to properly translate a matrix, we must increase the size from a 3 x3 to a 4 x4 by adding in a row vector of [0 0 0 1] and a column vector of [0 0 0 1]^{T} to the matrix C.

We must now perform a row and column concatenation to our matrix A before pre-multiplying by M. We concatenate a row vector of [1 1 1 1] which represents the row’s scale value.

If we change the order from Translate -> Rotate -> Dilate to Rotate -> Translate -> Dilate we would multiply as follows:

Thus it is easy to see mathematically that the order of multiplications does, in fact, have an effect on the final matrix. This verifies the findings shown in Figures 8 and 9.

## MATLAB CODE

- Main Code (with Airplane instantiation)
- dilate_3D function
- rotate_3D function
- translate_3D function
- plot_3D_object function