View Frustum plane calculation

Started by
4 comments, last by Void 22 years, 3 months ago
Hi, can anyone explain the idea behind calculating the 6 view frustum planes? I read Mark Morley tutorial. He combines the view matrix with projection matrix, and does some calculation to extract the plane''s equation. What is the formula/rationale he used to do the extraction calculation? Thanks.
Advertisement
I have no idea, but I''d like to know...

As we all do, don''t we?

Qatal

die or be died...i think
die or be died...i think
I''m not sure how he came up with it. As for why it works you have to lookup how the matrix is built in the documentation for glFrustrum. You can ignore the model view matrix by just making it the identity matrix. He is subtracting one of the first three rows from the fourth row.

Now ignoring what he did the normal for the right plane is (top,right,near) x (bottom,right,near) or (near*(top-bottom), 0, right*(bottom-top)). If you divide through by (top-bottom) you get (near, 0, -right). Now taking what he did you get (-2*near/(right-left), 0, -1-(right+left)/(right-left), 0) which simplifies to (near, 0, right, 0). You might notice that is not (near, 0, -right). I suspect that is actually the left hand plane since normally the z-axis goes straight through the center of the viewport so -right is left. None of his examples do anything where it matters which is left and which is right. Overall I don''t think it is some mathematical property as much as it is simply an encoding. It allows them to store the values in a manner that can be retrieved/used without affecting the projection operation.

I''m a bit confused on the model view part. That would seem to me to be projecting the model tranform which seems backwards to me. So my best guess is that I have it backwards and it is putting the projection matrix into model space. It seems like that would have to be the inverse of the model view, but apparently it works and apparently I''m wrong.
Keys to success: Ability, ambition and opportunity.
The model view part is correct because the planes calculated are to be in global world coordinates. (meaning the planes are calculated when the view matrix is identity, then transformed by the model view)

I can understand calculating the planes by crossproduct of the ray projections. What I cannot see is the maths behind extracting the rows of the matrix and subtracting/adding (and it works!)

The first 3 columns of a matrix in opengl defines the orientation of the x,y,z axis of that coordinate frame. What does the rows mean then?

As I understand, the projection matrix turns the view frustum into a canonical view volume ( a 3d cube ) through a translation and a kind of z shear (which is not homogenous). So how he extracts the planes from that matrix is still a mystery to me.
The projection matrix used by OpenGL is not:

  1  0  0  00  1  0  00  0  1  1/focus0  0 -1  0  


How the matrix is built is documented here. The actual matrix used by OpenGL is apparently the transpose of that matrix. If you work through the calculations he gave you get a scaled version of the cross product.
Keys to success: Ability, ambition and opportunity.
That is superby useful. Thanks!! I will digest it once the New Year mood passes.

..

This topic is closed to new replies.

Advertisement