I know of matricies in OpenGL and in my math class we just went over determinants. Are they of any importance in game programming?
Printable View
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).Quote:
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;
}
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.