Project 1A: Transformation Matrices Solution

$35.00 $24.00

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:   Write the code for gtInitialize() that initializes the matrix stack. After this command is called, the only matrix on the…

You’ll get a: . zip file solution

 

 
Categorys:

Description

5/5 – (2 votes)

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 4×4 identity matrix.

 

  1. 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]

 

 

 

  1. Create a routine that does 4×4 matrix multiplication, to be used in the next step.

 

  1. Create 4×4 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.

 

  1. 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.