# OpenGL modelview and projection matrices

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

## Recommended Posts

Hi guys, I've got a tough problem regarding the modelview/projection matrix in opengl.

Say, I have a set of 3D points, and also their corresponding 2D screen positions, is it possible to solve for the optimal modelview (or the scale/rotation/translation) matrix which transforms all these 3D points to the 2D screen positions, when the projection matrix is fixed? or, is it possible to solve for such a projection matrix, when the modelview matrix is fixed?

##### Share on other sites

Yes, that's possible in principle, but it's not simple.

Basically you just solve the resulting system of linear equations and you are done.

What makes this hard is that  the system may be massively over-determined.This means, that some equations contradict each other, so you have to find a way of resolving those contradictions.

Google for suitable algorithms, if unsure.

##### Share on other sites

Yes, that's possible in principle, but it's not simple.

Basically you just solve the resulting system of linear equations and you are done.

What makes this hard is that  the system may be massively over-determined.This means, that some equations contradict each other, so you have to find a way of resolving those contradictions.

Google for suitable algorithms, if unsure.

Yes, it may probably be a over-determined problem, that's the reason why I said "optimal". My question now is, whether it is simple to solve for such a modelview matrix (or the translation/rotation/scale matrix), or such a projection matrix? don't know if there's any prior attempts on solving this problem...

##### Share on other sites

In photogrammetry, this is a pretty standard problem, so we can consider it solved. ;-)

But as I already said: It is not simple.

You can probably get away with a reasonably good approximation by doing the following:

1) Solve the equation system for each pair of projected and unprojected points. This yields a transformation matrix for each pair.

2) Choose a good one from these by projecting all the points with each matrix and pick the one that produces the least error.

##### Share on other sites

In photogrammetry, this is a pretty standard problem, so we can consider it solved. ;-)

But as I already said: It is not simple.

You can probably get away with a reasonably good approximation by doing the following:

1) Solve the equation system for each pair of projected and unprojected points. This yields a transformation matrix for each pair.

2) Choose a good one from these by projecting all the points with each matrix and pick the one that produces the least error.

Do you mean I should compute such a transformation matrix which is one part of the modelview matrix? If yes, then the projection matrix and factors should be considered fixed for this problem, it is right?

• ### Game Developer Survey

We are looking for qualified game developers to participate in a 10-minute online survey. Qualified participants will be offered a \$15 incentive for your time and insights. Click here to start!

• 16
• 9
• 15
• 9
• 11