# Tag Info

### Why do we use 4x4 matrices to transform things in 3D?

3x3 matrices cannot represent 3D translations, but 4x4 matrices can A simple argument why 3D translations are not possible with 3x3 matrices is that translation can take the origin vector: ...

### How does a 4x4 matrix represent an object in space and matrix lore?

How is Matrix Multiplication a Transformation? A matrix is just a big grid of numbers with rules that define how we can multiply it with other grids or lists of numbers. In games, we usually want to ...
Accepted

### Why do we need a fourth coordinate to divide by z?

Because if you only divide [x, y, z] by z you get [x/z, y/z, 1] and you lost the actual ...

### How and when do the model to world, world to view, et cetera multiplications happen?

Think about it logically: What is your goal when you render something? To display it on the screen! What are the constraints? The model must be visible to the camera (i.e. in the view frustum, not ...
Accepted

### Do matrix manipulations for 3D graphics ever produce singular matrices?

The simplest way this can happen is if you shrink an object until its local scale in one or more axes is 0 (flattening it to a plane, line, or point). You can avoid this by disallowing scales below a ...
Accepted

### lookAt with orthographic camera (gl-matrix)

When I use the identity view matrix, I can see my model, but when I use LookAt, it is not visible. How can I see my model using ...

### Confused About My Code Suggesting The Normal Matrix Is Equivalent To The ModelView Matrix

When a matrix is orthogonal, inverse and transpose are equivalent making an inverse transpose equal to the original matrix. So if your model view matrix is orthogonal, the normal matrix will be equal ...
Accepted

### Finding islands from array

This is a standard computer science problem called connected component search. You can solve it in time linear in the number of cells using iterated depth-first / breadth-first search or a flood fill ...

### How do you make a camera look at a box and ensure all of it is visible?

Take every point (vertex), project them into screen space (basically multiply them with the projection * view * model matrix). After you got this, take every point ...
Accepted

### Extract a rotation matrix given a camera direction (vector) and a up vector for the camera?

NOTE: Edited because it was likely too verbose (source). A rotation matrix actually always defines an orthonormal basis. What this means is each column defines one of your original axes in its ...
Accepted

### How much matrices should I use for OpenGL transformation?

Your object is transformed in multiple steps, and for each step, you usually use a matrix. You can rotate, scale and translate every model. This can be done with three separate matrices, but usually ...
Accepted

### How to mirror/reflect/flip a 4D transformation matrix

To get a transformation matrix equivalent to the one you have, but reflected across a major axis you can compose it (multiply it by) a reflection matrix. That is, if you have your input matrix M and ...

### From 3d rotation, snap to nearest 90 directions

For anyone in the future looking for a solution to this using Unity/C#, here is an implementation I made based on Steve's answer: ...

### Fastest way to neutralize scale in the transform matrix?

Assuming your matrix multiplication follows the convention... M * v = (T * R * S) * v (where M is your composed matrix, ...
Accepted

### How to convert -1 to 1 coordinate back to screen coordinates?

For this problem specifically: screenX = ((glX + 1) / 2.0) * maxScreenX; screenY = ((glY + 1) / 2.0) * maxScreenY; In general, the solution for going from ...

### How do I create a view matrix that does not contain the camera translation?

In fact you don't need to create a second matrix separately. To remove any translation you just need to cast the matrix to mat3 and back to ...
Accepted

### Issues with OpenGL rotation matricies and shaders

You're off by 1 in your matrix initialization. The matrix rows are 4 entries wide (4x4 matrix) but you're initializing them like they're 3 entries wide. ...
Accepted

### multiply matrix4x4 with vec4

Matrix-vector multiplication works the same as matrix-matrix multiplication, because a 4d vector is basically matrix with one of the dimensions equal to 1. If we have a vector ...

### How much matrices should I use for OpenGL transformation?

In professional games every object in the world will have its own world matrix. This is usually stored in some structure that represents your entity in the world, or some component hanging off that ...
Accepted

### How to convert a 4x4 matrix transformation to another coordinate system?

This is as easy as writing your old coordinates in terms of the new ones. We want +x to map to +x (1, 0, 0) We want +y to map to +z (0, 0, 1) We want +z to map to -y (0, -1, 0) We want the fourth, ...
Accepted

### Tetris: 2D Rotation Matrix?

At 90 degrees, you can work out rotations in both directions just by swapping and reversing positions. Begin with the following shape: Ahead, we rotate it manually clockwise, and look at the ...
Accepted

### Cumulative transformation matrices for hierarchical object transformations

So firstly, I'd like to apologize if my question was poorly worded or if it was just confusing in general. I think I've figured out the proper solution now. It took a while because I had passed it off ...
Accepted

### Change value of uniform for each VAO

You can make a uniform for as many things as you want, including per object. If you want object A) to have a different uniform then object B), then create one for each item and bind it to the shader ...
Accepted

### Projection Matrix Breaks My Rectangle

First of all, there's something fishy about your vertices. If we write them out properly: ...
Accepted

### Get the difference between 2 matrices

Your problem is that you're trying to compare floating-point numbers for equality. The matrix inversion and multiplication, however, will inevitable introduce slight rounding errors that will make ...