Hot answers tagged

17 votes

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 ...
user avatar
  • 115k
16 votes

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: ...
user avatar
15 votes
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 ...
user avatar
  • 23.4k
11 votes

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 ...
user avatar
  • 491
8 votes

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

To succinctly answer the "why" question, it's because a 4x4 matrix can describe rotation, translation, and scaling operations all at once. Being able to describe any of these in a consistent manner ...
user avatar
  • 181
8 votes

Is a dynamic enviroment map using pincushion curvilinear perspective projection possible?

In practice, even when a scene is built to minimise problems, a 360-degree-FOV camera tends to introduce so much distortion in some directions that its results are useless for most purposes. If you ...
user avatar
8 votes
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 ...
user avatar
  • 115k
8 votes
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 ...
user avatar
  • 8,964
7 votes

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 ...
user avatar
7 votes
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 ...
user avatar
  • 115k
6 votes
Accepted

OpenGL light appears to move with camera and changes with object rotation

From what I read from the shaders the light is in world-space and the light calculation is done on the object in part in untransformed object-space. You need to compute your lighting with both light &...
user avatar
6 votes

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 ...
user avatar
  • 14.5k
5 votes

Is a dynamic enviroment map using pincushion curvilinear perspective projection possible?

The short answer is: yes, it is possible, but since the projection you desire is nonlinear, you must do one of two things: Subdivide the geometry finely and implement the projection math in the ...
user avatar
  • 33.2k
5 votes

How can I reverse the effect of a transformation matrix?

If your transformation matrix is a rotation matrix then you can simplify the problem by taking advantage of the fact that the inverse of a rotation matrix is the transpose of that matrix. If your ...
user avatar
5 votes
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 ...
user avatar
  • 351
5 votes
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 ...
user avatar
  • 18.9k
4 votes

How to rotate a set of points on z = 0 plane in 3-D, preserving pairwise distances?

If I understand correctly, you have three points A, B, C, and three points ...
user avatar
  • 23.4k
4 votes

Offset a camera/render without changing perspective

Wow that was fast. It's crazy how sometimes just writing out the question helps you figure out how to approach a solution. Here is my matrixPerspective function: ...
user avatar
  • 1,901
4 votes

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: ...
user avatar
4 votes
Accepted

what is the very last element of a 4x4 transformation matrix for?

The value is for Homogeneous Coordinates. Using homogeneous coordinates makes it possible to use things like quaternions and projection matrices. The last entire row is actually for dealing with ...
user avatar
4 votes
Accepted

Inline-Building a World (SRT) Matrix

A homogenous transformation matrix (aka a "World matrix") is a 4x4 matrix that defines the translation and rotation of one coordinate system with respect to another. It looks like this: ...
user avatar
  • 3,567
4 votes

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, ...
user avatar
  • 115k
4 votes
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 ...
user avatar
4 votes
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 ...
user avatar
  • 8,740

Only top scored, non community-wiki answers of a minimum length are eligible