Skip to main content
11 votes

Why are width and height divided by 2 in the perspective projection matrix?

Because $x_{proj}$ doesn't vary from $0 \to width$, it varies from $-\tfrac{width}{2} \to \tfrac{width}{2}$. What's important is not the width, but the minimum and maximum values of $x_{proj}$. ...
Dan Hulme's user avatar
  • 6,880
9 votes

Why does opengl use 4d matrices for everything?

So, A lot of folks would tell you that a 4x4 matrix is used so you can get a translation component rolled into your linear transformation. Meaning that with a 3x3 matrix you can only compute rotations,...
pmw1234's user avatar
  • 3,484
8 votes
Accepted

How to translate object to origin?

No, he's talking about subtracting the position of the cube from the vertex positions, so that your cube is positioned at the origin. If you positioned the cube at (10, 30, 15), you subtract that ...
Alan Wolfe's user avatar
  • 7,811
7 votes
Accepted

What does it *mean* to scale in an arbitrary direction?

When you scale along the X-axis, the X-coordinate (parallel to the axis) gets stretched, while the Y-coordinate (perpendicular to the axis) remains the same. You can think of scaling along an ...
russ's user avatar
  • 2,402
7 votes
Accepted

Why do we multiply vertex from left side in vertex shader with matrices?

There is no 100% consensus on what order matrix multiplication should model things, worse the industry is split along this. Some sources use row major and some sources use column major matrices. Great ...
joojaa's user avatar
  • 8,457
7 votes
Accepted

Render with camera perspective off-center

Yes, you can use an off-axis projection matrix. This is what I use in my code (note: I shift the centre upwards, not left as you do in your example.) ...
Bram's user avatar
  • 280
6 votes

Solving a problem from *Foundations of Computer Graphics*:

Let me try to make my comment into a complete answer. The general idea is to build a linear system using those 6 point pairs and solve for the desired 12 unknowns. You may find this paper[1] useful ...
TheBusyTypist's user avatar
5 votes

How is that possible that matrices can be thought as coordinate systems?

If you have a 3x3 matrix representing some transformation, you will actually have the X,Y,Z vectors of that transformation in the rows or columns (depending on if it's a row major or column major ...
Alan Wolfe's user avatar
  • 7,811
5 votes

Why do we multiply vertex from left side in vertex shader with matrices?

OpenGL uses column-major matrices. For example, the translation values will be in the last row rather than the last column of the matrix. For example when loading matrices into uniforms in glsl, the <...
user1118321's user avatar
  • 3,441
5 votes

why is translating in 3D space the same as shearing in 4D space?

In a linear transformation system, your origin is always a fixed point, since 0*anything = 0. So imagine you have a cinema screen, and the origin is at the centre of the screen. Using linear ...
russ's user avatar
  • 2,402
5 votes
Accepted

Screen space coordinates to Eye space conversion

Object Space → World Space → Eye Space → Clip Space → Normalized Device Space → Window Space You get from Object Space to World Space by multiplying by the "World Matrix" (This may actually be ...
Wyck's user avatar
  • 410
5 votes

Why does opengl use 4d matrices for everything?

The bottom row allows you to create perspective foreshortening. That is, it makes lines that are getting further away appear to converge. When arranged this way, we call this a perspective projection ...
user1118321's user avatar
  • 3,441
4 votes

What's a parent vector space or coordinate system?

You have to step outside the world of mathematics for a while and look at what we are trying to achieve. Mathematics in its purest form only tells us what kinds of properties certain constructs have, ...
joojaa's user avatar
  • 8,457
4 votes
Accepted

How to derive a perspective projection matrix from its components?

The second matrix translates the eye [...] You don't do that in a projection matrix. You do that with your view matrix: Model (/Object) Matrix transforms an object into World Space View Matrix ...
Tare's user avatar
  • 1,613
4 votes
Accepted

Inverse matrix order of operation

Yes. If you're compounding operations to make a matrix, then the inverse matrix will be the compound of the inverse operations, in the reverse order. So if $C = AB$ then $C^{-1} = B^{-1}A^{-1}$ Think ...
russ's user avatar
  • 2,402
4 votes
Accepted

Is it possible to make a projection matrix to not project in the center?

It's not possible to cut a hole in the image by altering the projection matrix, no. However, you can mask out rendering in that region by using the depth test or stencil test. For example, before ...
Nathan Reed's user avatar
  • 25.3k
4 votes

Applications of the outer product in shaders

You can construct the orthogonal projection matrix onto $u$ as $P= uu^T$ if $u$ is unit length, otherwise it is $P_{u,u^{\perp}}=u(u^Tu)^{-1}u^T = \frac{uu^T}{u^Tu}$. If you have $P_{u,v^{\perp}}=u(v^...
lightxbulb's user avatar
  • 2,561
3 votes
Accepted

Unable to pass custom Matrix4 to GLSL as a uniform

glUniformMatrix4fv(transformLocation, sizeof(transform), GL_FALSE, &transform.m[0][0]); The second parameter to ...
Nicol Bolas's user avatar
  • 9,997
3 votes

row and column majored rotation matrix pre- or post- multiplied

Okay let us start by pointing out that a colmun major matrix is the same as a transposed row major matrix. So: $$ {M_{cm}}^{T} = M_{rm} \tag{1} $$ Then notice that matrixes have following properties....
joojaa's user avatar
  • 8,457
3 votes

Ladder to DNA using Transformation Matrix

You can't perform this transformation by applying constant transformation matrix to the ladder model since it's not linear transformation like joojaa said in the comments. What you would have to do ...
JarkkoL's user avatar
  • 3,686
3 votes

How is that possible that matrices can be thought as coordinate systems?

A matrix can be used to transform a coordinate system into a new one. More specifically, it can be used to transform the basis vectors of a coordinate system. That's how it defines a new coordinate ...
Olivier's user avatar
  • 1,585
3 votes
Accepted

Detect a lossy matrix decomposition?

You can detect a matrix that can't be decomposed in TRS form by taking its 3×3 upper-left submatrix, interpreting its columns as vectors, and dotting them together in all combinations (1 with 2, 2 ...
Nathan Reed's user avatar
  • 25.3k
3 votes
Accepted

Do I need a normal matrix if I calculate lighting in an objects space?

By lighting in object space, sure, you could avoid transforming the normals into world space. However, you'd have to transform the light positions/vectors into the object's space. Also, if you want ...
Nathan Reed's user avatar
  • 25.3k
3 votes
Accepted

Move the camera in orthographic 3D

It seems that some basic computer graphics knowledge is missing. Normally you have two matrices for the camera (viewMatrix and projectionMatrix), both are 4x4 matrices. The viewMatrix stores the ...
Thomas's user avatar
  • 1,366
3 votes
Accepted

New QEM, question about degenerate case

When they solve $Av=-b$ the assumption is that $A$ is non-singular. Whenever $A$ is singular the problem can either have no solution, or infinitely many solutions. In their case I believe it is the ...
lightxbulb's user avatar
  • 2,561
2 votes

How to translate object to origin?

Normally woth rotating objects in 3d you have a pivot. With rotation matrices it is assumed that the pivot is at (0;0;0), the origin. This means that if the pivot is not at (0;0;0), you have to move ...
bram0101's user avatar
  • 1,615
2 votes

Correctness of logical steps for create the matrix of viewing transformation

I would like to address an issue in your naming. This issue makes the question a bit odd, but not impossible, as I will try to show. There is an, often unspoken, implied relationship between the ...
joojaa's user avatar
  • 8,457
2 votes

Correctness of logical steps for create the matrix of viewing transformation

I'm assuming you mean $A$ is object$\rightarrow$world matrix and $B$ is your camera$\rightarrow$world matrix? If that's the case, to calculate object object$\rightarrow$camera matrix you calculate: $$...
JarkkoL's user avatar
  • 3,686
2 votes
Accepted

Rotation matrix for a 3D object in space

Skimming the math. Starting with a quaternion $Q=w+\left(x,y,z\right)$ then we can rotate $\mathbf{v}$ by: $$\mathbf{v}' = Q\mathbf{v}Q^{-1}$$ and if $Q$ is unit magnitude this reduces to: $$\...
MB Reynolds's user avatar
2 votes

What's a parent vector space or coordinate system?

First start to be sure you understand what matrices are (4x4 which are the most common in CG). 1) about your first question. You are taking about a hierarchy of transforms. I don't know if you use ...
user18490's user avatar
  • 656

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