# Extract view frutum planes from view matrix

Is that possible?
How is that done?

And I’ve got another question on a similar topic; why bother if you can just run the corners of the bounding box through the perspective matrix and check them against clip space?

If you want to check for frustum-aabb intersection in homogeneous clip space, it is usually better to do so in modelview or world space.

Extracting frustum planes from the modelview matrix is not practical. You can only transforms planes with the modelview matrix. Plane extraction is usually done with perspective matrices; usually it can be avoided.

I want to do this

http://www.gamedev.net/community/forums/topic.asp?topic_id=224424&whichpage=1

Thats why I need the planes. It is just for debugging now.

I think the usual world space and modelview space aabb-frustum cull algorithm handles the border case very well, check this:

http://www.lighthouse3d.com/opengl/viewfrustum/index.php?remarks

I haven’t had any problem with the border case you describe yet. The nice thing about frustum planes is that they depend at most on 2 variables in modelview space, just visualize them, for example the top plane

``````
t
y  /
^ /
z  |/
<--O

``````

and you can write y = -t/n * z and you get:

-ny - tz = 0 for the top plane equation. Here I took into account, that n is a positive number in OpenGL. Also, you have to be careful which way the normal is pointing (here, it points into the frustum). Here are all the plane equations in modelview space, with normals pointing into the frustum:

frustum_planesa = GetN(frustum), 0, GetL(frustum), 0;
frustum_planesa = -GetN(frustum), 0, -GetR(frustum), 0;
frustum_planesa = 0, GetN(frustum), GetB(frustum), 0;
frustum_planesa = 0, -GetN(frustum), -GetT(frustum), 0;
frustum_planesa = 0, 0, -1, -GetN(frustum);
frustum_planesa = 0, 0, 1, GetF(frustum);

Some books make the derivations of these look like black magic. Once you have these you can just multiply them with inverse transposes of transformation matrices. If I want to transform them into world space, for example, I multiply the transpose of the modelview matrix with them. From literature, you usually “extract” matrices from the projection matrix, as plane equations in homogeneous clip space are simple (they bound a cube), but in most cases, it is better to just jot down the plane equations in modelview space, as I have, and transform them into whatever space you want them in. You might also want to normalize the normals, for plane distance calculations. If you do, find the norm of the normal (first 3 plane coefficients) and divide all the plane coefficients by it.

Otherwise go to: