The Power of the Matrix Help

Your browser doesn't appear to support the canvas element. Your browser doesn't appear to support the canvas element.

Mouse X: 0 Mouse Y: 0
Original Vertex Matrix
Close

When you click update or hit enter, the rotation and translation of the cube changes by the corresponding amounts in each input area (you can edit these). You will see the cube transformed in 3D space and return to its starting position once its Y value has exceeded a certain amount. The Mouse X and Mouse Y text tells you where your mouse is in the two dimensional canvas. The top right corner is (1,1) and the bottom left is (-1,-1). The Original Vertex Matrix is the original 8 vertices of the cube before it was transformed. On the right you see matricies labeled 0-6, with a corresponding explanation (The Model View Matrix(4) is the Y Rotation times(3) the X Rotation(2) times the translation(1)). The Model Vertex Matrix(5) is the Model View Matrix(4) times the Original Vertex Matrix. Finally, the Screen Vertex Matrix(6). First, do Perspective Matrix(0)*Model Vertex Matrix(5) and store it in a 4 by m(number of vertices) matrix called A. Then, to find the X screen coordinates (from -1 to 1), we divide every element in the 1st row of A by every element in the 4th row of A (1st vertex screen x position=A11/A41). To find the Y screen coordinates, we divide every element in the 2nd row of A by every element in the 4th row of A (1st vertex screen y position=A21/A41). You can verify this by moving your mouse over vertex 1 on the cube and comparing it to the fist column in Screen Vertex Matrix(6) (They should be pretty close). In other words, the first two rows of the Screen Vertex Matrix are the x and y positions of the vertices on the screen and the third row is depth information to calculate which vertices can't be seen.