# Is view matrix always invertible? How change base of plane equation?

This topic is 4477 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Is a view matrix always invertible? I made a proof attempt but it failed, so I made a simpler proof sketch instead: since it represents a base change in the 3*3 upper left corner, and a translation in the bottom left corner, and the rightmost row is equal to identity, undoing the translation and rotation should be possible. Is that correct? My second question is how to change base of a plane equation? I manage to change base of the normal vector, but when I get to the d parameter, I obtain this expression:
sqrt( (d*nx-x)^2 + (d*ny-y)^2 + (d*nz-z)^2 )

where d is the old d parameter, nx,ny,nz are the old normal vector parameters, and x,y,z are the amounts of translation the new view matrix does compared to the old base. Is this expression correct, or are there simpler methods of changing base of a plane, such as multiplying the 4 vector by a 4*4 matrix? My final question is how to extract view frustum planes from a projection matrix and get the plane equations in world space, both for the case of a normal projection matrix, and for the case of an orthogonal projection.

##### Share on other sites
A view matrix is a scale/rotation multiplied by a translation matrix.

Inverse(AB) = Inverse(B) * Inverse(A)

so if A and B are invertible then so is AB.

##### Share on other sites
Quote:
 Original post by all_names_takenMy final question is how to extract view frustum planes from a projection matrix and get the plane equations in world space, both for the case of a normal projection matrix, and for the case of an orthogonal projection.
Google 'Inequalities for the Homogeneous Clipping Space', and you'll find a good article on the subject.

[Edit: John provided a link (below) to the paper I had in mind.]

[Edited by - jyk on August 13, 2006 7:10:57 PM]

##### Share on other sites
Quote:
 Original post by all_names_takenMy final question is how to extract view frustum planes from a projection matrix and get the plane equations in world space, both for the case of a normal projection matrix, and for the case of an orthogonal projection.

The standard reference: Fast Extraction of Viewing Frustum Planes from the World-View-Projection Matrix

##### Share on other sites
Quote:
Original post by JohnBolton
Quote:
 Original post by all_names_takenMy final question is how to extract view frustum planes from a projection matrix and get the plane equations in world space, both for the case of a normal projection matrix, and for the case of an orthogonal projection.

The standard reference: Fast Extraction of Viewing Frustum Planes from the World-View-Projection Matrix

the odd thing is that when I use that method, my far plane gets normal=(0,0,-1) and d=1, even though I created my projection matrix with the setting that far plane would be 20000.0 away. Logically, if the far plane is set to be 20000.0 units away, then the plane extraction of far plane, when positioned at 0,0,0 and looking at 0,0,1 should yield d=20000.0, but it doesn't...

So I've tried to think up an own method for plane extraction. The above method in my tests gets the normals right, but the d parameter wrong. In view space, all planes except far and near plane have d=0, so I could extract the planes from the projection matrix using above method, then manually setting d to 20000 for far plane and 1 for near plane, then finally transform the plane equations of all the planes using the inverse of the view matrix, to get them in world space.

##### Share on other sites
Quote:
 Original post by all_names_takenthe odd thing is that when I use that method, my far plane gets normal=(0,0,-1) and d=1, even though I created my projection matrix with the setting that far plane would be 20000.0 away. Logically, if the far plane is set to be 20000.0 units away, then the plane extraction of far plane, when positioned at 0,0,0 and looking at 0,0,1 should yield d=20000.0, but it doesn't...So I've tried to think up an own method for plane extraction. The above method in my tests gets the normals right, but the d parameter wrong. In view space, all planes except far and near plane have d=0, so I could extract the planes from the projection matrix using above method, then manually setting d to 20000 for far plane and 1 for near plane, then finally transform the plane equations of all the planes using the inverse of the view matrix, to get them in world space.
I wouldn't be so quick to implement your own method because you encountered problems with the algorithm as described in the paper. That paper has been around for a while and the algorithm has been used by many people. At this point I think it would be safe to say that it works. I can say that I've used it successfully myself, and have also worked through the derivation and confirmed that the algorithm is correct (just for my own edification).

IMO it's more likely that you've implemented the algorithm incorrectly or made an error elsewhere. Keep in mind that there are two versions of the algorithm presented in the paper: one for DirectX, and one for OpenGL. The two differ in terms of matrix indexing and calculations involving the near-z clipping range. If you get either of these wrong your results will be incorrect. Also, you may need to normalize the planes after extraction to get the results you're expecting. [Edit: It looks like you're getting unit-length normals, so that may not be the problem.]

I would suggest sticking with the algorithm (which is well established) and looking for an error in either your implementation or your use of the algorithm.

[Edit: IIRC, there may be a typo in one of the sections that describe how to concatenate the view and projection matrices, so make sure that you have the order correct for the vector convention you're using. Off the top of my head, it should be P*V for column vectors and V*P for row vectors.]

##### Share on other sites
1. it seems I keep getting errors, but I'll devote one more day to reviewing my implementation of it tommorrow. I'm currently using DirectX.
2. does the method from the paper also work for calculating the clipping planes of an orthogonal projection matrix?

##### Share on other sites
Quote:
 Original post by all_names_taken2. does the method from the paper also work for calculating the clipping planes of an orthogonal projection matrix?
Yes :)

1. 1
Rutin
40
2. 2
3. 3
4. 4
5. 5

• 18
• 19
• 12
• 14
• 9
• ### Forum Statistics

• Total Topics
633362
• Total Posts
3011531
• ### Who's Online (See full list)

There are no registered users currently online

×