$29
In order to familiarize you with matrix transformations and operations, you will be completing the empty methods that are modeled on the corresponding commands from OpenGL. You will write code to do the following:
1. Write the code for gtInitialize() that initializes the matrix stack. After this command is called, the only matrix on the stack should be the 4x4 identity matrix.
2. Print the current transformation matrix (the top of the stack) to the Processing console. Make sure your matrix prints on four separate rows. For output that is easier to read, have this command print an empty line after the last row. The command for this is print_ctm().
Example:
[1, 0, 0, 0]
[0, 1, 0, 0]
[0, 0, 1, 0]
[0, 0, 0, 1]
3. Create a routine that does 4x4 matrix multiplication, to be used in the next step.
4. Create 4x4 scale, translate, and simple rotation matrices, and multiply the matrix on the top of the stack with this newly-created matrix. The names of the commands that you will implement are gtScale, gtTranslate, gtRotateX, gtRotateY, gtRotateZ. For instance, gtScale will cause this change to the top of the matrix stack: new_ctm = old_ctm * scale_matrix.
5. Implement gtPushMatrix and gtPopMatrix. The gtPushMatrix command duplicates the current transformation matrix and places this copy on the top of the matrix stack. The gtPopMatrix command pops the current transformation matrix off the top of the stack. If there is just one matrix on the stack, gtPopMatrix should print an error message.