This is more or less what gluProject() does, except gluProject() also takes the current viewport into account and takes a separate modelview matrix into account (we can just assume the modelview matrix is the identity matrix). ![]() Projecting each of these 3D coordinates into 2D is done by multiplying the 4D vector with a 4x4 projection matrix, then dividing the x and y components by z to actually get the perspective correction. ![]() In other words, a unit square in the y=0 plane. Let's say we use GIMP to find the 2D coordinates of what we think is a square on the ground plane (whether or not it is really a square depends on your judgment of the depth): Here is a still photo from Thomas the Tank Engine: Very simply put, the algorithm is as follows: Randomly perturb your projection matrix until it projects your known 3D coordinates to your known 2D coordinates. Alright, I came here looking for an answer and didn't find something simple and straightforward, so I went ahead and did the dumb but effective (and relatively simple) thing: Monte Carlo optimisation.
0 Comments
Leave a Reply. |