I have been given the following Maya camera data:
trans X: 1.542
trans y: 3.319
trans z: -1.821
rot X: 117.882
rot Y: 2.189
rot Z: 154.074
scale X: 1
scale Y: 1
scale Z: 1
What is the formula for converting this to a 4 x 4 transformation matrix?
I don't have time currently to give a complete answer here, because it's fairly in-depth and I'm short on time, but the information I do have time to give is too much to fit in a comment, so I'll give what I can, for whatever it's worth.
First of all, it appears that Rot X, Y, and Z are in euler angles (degrees rotated around an axis). It would depend on which way that rotation goes (clockwise or counterclockwise). And it depends if Maya represents the degrees between 0 and 360, or -180 and 180, if it's -180 to 180 then just add 180 to whatever output Maya gives.
You'll need to convert degrees to radians for each of them by multiplying them by PI / 360. Then convert the radians to an euler angle to determine the rotation's fwd, up, and right vector's. The forward will be represented by Z in most coordinate systems, right represented by X, and up represented by Y, although if you're exporting for a different coordinate system this may differ.
Once rotation is represented by three vectors, it becomes the first three columns (or rows in some systems) or your 4x4 matrix.
The 4th column is the position/translation vector.
Depending on the system using the matrix, I believe the entire matrix's diagonal can be used for scale, or sometimes just the Translation's W coordinate.
An identity matrix would look something like below, giving a rotation in which an object's forward is along Z, its right is along X, and its up is along Y, and it's at position (0, 0, 0).
Assuming you know how to construct the individual matrices, I believe the correct order of transformations - going from a node's coordinates to its parent's coordinates - is scale, then rotation in X, Y, Z order, then translation.
Depending on whether your system uses row vectors or column vectors, that will be S * Rx * Ry * Rz * T, or T * Rz * Ry * Rx * S, respectively.
A note on rotation order: Maya doesn't have a concept of "roll", "pitch", or "yaw". It deals with rotations just in terms of axes, and assumes that rotations are always applied in X, Y, Z order. So the natural interpretation would be X = roll, Y = pitch, and Z = yaw.
The matrix I'm using is a row-major matrix used by OpenGL. Here's what it looks like:
What you have is actually three matrices: a rotation matrix, a scale matrix and a translate matrix. This is because virtually any 4x4 matrix can be broken down to two or more matrices that together form the original matrix. A matrix concatenation looks like this:
So let's get down to business. First, we have the scale matrix:
The rotational matrix can be further broken down to a matrix on the x-, y- and z-axis.
Rotation over x-axis:
Rotation over y-axis:
Rotation over z-axis:
So our final rotation matrix becomes:
Finally, the translation matrix:
Putting it all together:
If you want, you can write out all the concatenations and get a valid matrix. But I believe it's easier to keep it in either separate matrices like I've done or in matrix operations (