I know of matricies in OpenGL and in my math class we just went over determinants. Are they of any importance in game programming?
This is a discussion on determinants within the Game Programming forums, part of the General Programming Boards category; I know of matricies in OpenGL and in my math class we just went over determinants. Are they of any ...
I know of matricies in OpenGL and in my math class we just went over determinants. Are they of any importance in game programming?
determinants have a huge importance in game programming. Doing a vector cross product (which uses determinats) will get you the normal vector to a point/surface, etc. Just one example of this being used is most lighting algorithms. Other parts of graphics such as camera/screen orientation use them extensively as well, which is why it's programmed into OpenGL and DirectX.
How does doing a vector cross product use determinants? Maybe there's something in the theory I've missed, but I thought a determinant is basically just a number which you must compute along the process of calculating the inverse of a matrix.
The determinant of a 3x3 matrix is calculated and returned by this function:
I'm pretty sure that once you have that number, you just divide each element by the determinant, after you've check that the determinant isn't zero (if it's zero, I think that means it's already its own inverse or something like that).inline float det3x3(float a1, float a2, float a3,
float b1, float b2, float b3,
float c1, float c2, float c3)
{
return a1*b2*c3+a2*b3*c1+a3*b1*c2-a3*b2*c1-a1*b3*c2-a2*b1*c3;
}
Last edited by Darkness; 11-18-2004 at 05:28 PM.
See you in 13
"...the results are undefined, and we all know what "undefined" means: it means it works during development, it works during testing, and it blows up in your most important customers' faces." --Scott Meyers
That's cool, I guess I never really examined any formal proofs of cross product, which is why I didn't know where the determinant came into play.
See you in 13