**1**

# what is a practical use for the determinant of a matrix?

###
#2
Crossbones+ - Reputation: **3971**

Posted 14 September 2011 - 12:37 AM

Hi, just so I can better understand the matrix. Can one of the math gurus out there give me an example of the practical use of the determinant of the matrix AND the transpose of the matrix?

Thanks

Nikos

When a matrix is used to represent linear transformations (as is commonly the case in 3D graphics), the determinant effectively represents the degree of unambiguousness inside a matrix.

That is, if determinant is non-zero, the matrix can be inverted because the components don't "cancel out" each other (which would cause zero determinant).

In the same context, transpose of a 3x3 orthogonal rotation matrix is effectively its inverse. This works because the vectors within the 3x3 matrix represent the per-direction scaling factors caused by rotation, and if the vectors represent unique directions with regard to each other (orthogonality), those scaling factors can be simply flipped around to cancel the rotation that the original matrix represents.

In computer graphics, a full transpose of a 4x4 matrix can be done to save some GPU operations. This is related to the physical register layout and the instructions needed to multiply matrices.

Do note that in general, matrices can also be used to represent various other stuff in addition to linear transformations. Therefore, "the matrix" is ambiguous by itself.

Again, in general, matrix inversion is useful if you know the result vector and the linear formula (coefficients of which is what a matrix represents), and you want to find the original vector.

Niko Suni

###
#3
Members - Reputation: **1906**

Posted 14 September 2011 - 01:40 AM

If you put a unit cube through the transform, then the determinant will tell you what the volume of the output cube will be; in other words it tells you the volume scaling that the matrix will do.

Hence, well behaved 3D transforms will all have positive non-zero dets; and all rotation/translations which you expect to do no scaling will have a det of 1.

This also helps explain why zero det matricies can't be inverted. In order for it to have det zero, it must shrink one of your unit cube dimensions to zero. Hence there can't be a matrix which goes the other way, because there's no way to reinflate that deleted dimension back to one. Hence there's no inverse for the matrix.

Obviously, since you HAVE to squash one of the dimensions away to go from the 3D world to the 2D render plane, this means all projection matricies must have det = 0. And hence, this is why there is no general case system for taking a pixel in the window and finding it's location in 3D space, because that would amount to being able to invert your projection matrix.

###
#4
Members - Reputation: **158**

Posted 14 September 2011 - 05:44 AM

Hi, just so I can better understand the matrix. Can one of the math gurus out there give me an example of the practical use of the determinant of the matrix AND the transpose of the matrix?

Thanks

Nikos

Most of linear algebra is essential to understand 3d programming and graphics techniques. If you are doing lighting or something related like bump mapping, sometimes you need to convert coordinates from one space to another like convert coordinates to eye space, tangent space, etc... To do that, you come up with a change of basis matrix which is composed of three linearly independent vectors. Let's say you have three candidate vectors but you can't tell whether they form a basis or not. To check that your vectors are linearly independent and hence, form a basis for the space, you could take the determinant of the matrix composed of the three candidate vectors as columns. If the determinant of this matrix is non-zero, then the vectors are linearly independent and you found a basis. This, for example, applies to the famous TBN matrix that you will encounter if you read bump mapping articles. Even just coming up with candidate vectors involves solving systems of equations and using cross-products--all of which make heavy use of the determinant. See http://www.blacksmit..._derivation.php and http://www.blacksmit...ng_using_cg.php for example if you want to know how bump mapping works.

One use for the transpose is that it tells you when a matrix is orthogonal. When a matrix is orthogonal, then its inverse is the same as the transpose. This will be the case for rotations and translations and is good to know so that you can optimize code. When you pass normals to a shader, you won't need to multiply by the normal matrix if all you are doing are rotations and translations. This is because the normal matrix is the inverse transpose which means it's the actually the same as the orthogonal matrix. The TBN matrix that I mentioned above is also orthogonal and knowing this fact makes going from tangent space to world space easy.

http://www.lighthous...-normal-matrix/

###
#6
Crossbones+ - Reputation: **19324**

Posted 14 September 2011 - 09:15 AM

The signed area of a triangle is

| x1 y1 1 |

| x2 y2 1 | * (1/2)

| x3 y3 1 |

The signed volume of a tetrahedron is

| x1 y1 z1 1 |

| x2 y2 z2 1 | * (1/6)

| x3 y3 z3 1 |

| x4 y4 z4 1 |

Determinants can be used to solve systems of linear equations (Cramer's rule).

The determinant can be used to compute the eigenvalues of a matrix.

The transposed of a rotation matrix is its inverse.

If you have a system of linear equations with more equations than variables, you can reduce the number of equations by multiplying both sides of the equation in matrix form by the transpose of the matrix. The solution of the resulting system is the minimum-squares approximation to the first problem.

###
#7
Members - Reputation: **720**

Posted 14 September 2011 - 09:50 AM

The sign of the determinant of a matrix can be used to calculate the relative position of a point to a plane:

Given four points a=(ax,ay,az), b=(bx,by,bz), c=(cx,cy,cz) and d=(dx,dy,dz) the sign of the determinant of the matrix defined as

[a,b,c,d]=

|ax-dx ay-dy az-dz|

|bx-dx by-dy bz-dz|

|cx-dx cy-dy cz-dz|

shows you the relative position of d compared to the plane defined by a,b,c.

This helps, for example when testing intersections between triangles.

edit: damn editing the post totally messed up my awesome matrix. put in a new line...

###
#9
Members - Reputation: **132**

Posted 24 October 2011 - 09:41 PM

If you're working in 3D and using 4x4 matricies as transforms, the determinant has an immediately useful value.

If you put a unit cube through the transform, then the determinant will tell you what the volume of the output cube will be; in other words it tells you the volume scaling that the matrix will do.

Hence, well behaved 3D transforms will all have positive non-zero dets; and all rotation/translations which you expect to do no scaling will have a det of 1.

This also helps explain why zero det matricies can't be inverted. In order for it to have det zero, it must shrink one of your unit cube dimensions to zero. Hence there can't be a matrix which goes the other way, because there's no way to reinflate that deleted dimension back to one. Hence there's no inverse for the matrix.

Obviously, since you HAVE to squash one of the dimensions away to go from the 3D world to the 2D render plane, this means all projection matricies must have det = 0. And hence, this is why there is no general case system for taking a pixel in the window and finding it's location in 3D space, because that would amount to being able to invert your projection matrix.

Awesome reply. Thank you Katie

###
#11
Members - Reputation: **2143**

Posted 25 October 2011 - 01:44 PM

A determinant of zero effectively means there are infinite solutions of x to a system of equations, therefore there is no unique solution.

This is not strictly correct.

A 1x1 matrix M = [ 0 ] has a determinant of 0, but M*x = 5 does not have a single solution x. (while a trivial example in 1D, it is easy to construct counterexamples for nD as well)

A n-dimensional matrix that is not of full rank (it's column [or row] vectors don't span a n-dimensional space) has a determinant of zero. For a system of linear equations Mx=y, where M is not of full rank, there exists an infinite number of solutions only if y is in the range of M, and the dimension of the solution space is the same as the dimension of the kernel space of M (the degree of freedom for the system).