Help to find the transform matrix

Please help me with the following problem:

After a simple object with known dimensions is projected to a viewport, I’m able to find enough points on the viewport that correspond to the known points on the object. Is there any easy way to find the final transform matrix? Any link, math mdel, open source code etc? I’m new to the forum and just started OpenGL programming. Please help.

Originally posted by cxqiu:
I’m new to the forum and just started OpenGL programming. Please help.

And as is often the case you jumped straight into the ADVANCED opengl forum.

a) Buy the Red Book (it has documentation on how the matrices are calculated etc.)

b) Lookup glGetFloat

Hello,

that isn’t an opengl problem; that’s a parameter minimisation problem. I know very little about geenral schemes for minimisation (I use simulated annealing and particle filters in my work), but the basic idea is

  • form some model you wish to fit to yoru data. This model would consist of some parameters you want to solve;
  • construct a cost function that measures the error between your model parameters and the data you have
  • iteratively find the parameters that minimise the error using some minimisation scheme.

Consider a very very simple example. Suppose you had some points that you know fit a line, but you don’t know the line parameters. The model of this system is y=mx+c, ie. a line equation, and your parameters to this model are m (the slope) and c (the y-intercept).

There are two cost functions you could try – geometric least-squares and algebraic least-squares. The way you compute the error for geometric least squares is the sum of the distance for each point to the line with the two parameters set to some “hyptothetical value”.

Now… the way you choose these hypotehtical values and adjust them to mininise the error varies depending on what minimiser you want to use. The easier to summarise now (after going down to the unibar and having an extended lunch because my scholarship has been extended for 6 months! yer!) is hill climbing: choose two parameters at random from the parameter space and compute the error. keep doing this until you find two parameters that minimise the error, accepting only the parameters that reduce the error. As you iterate through different possibilities you slowly decrease the range the parameters may change from the previous generation to the next. Hilil climbing is NOT the best solution for everything: it is simple to implement and udnerstand, but it gets caught by local minima.

Anyway. Keywords to look up: numerical optimisation (or, “optimization” if you’re american), and… uh… no, that should be about it

it isn’t an opengl problem

enjoy
cheers
John

Hello Rgpc & John:

Thanks for the reply. John, I do agree with you that it is a numerical optimization problem and indeed appreciate your explanation in the reply.

The reason I posted the question here was that OpenGL has function calls to map between viewport points and object coordinates based on known rotation, translation, scaling, and projection matrices. There might be scenario OpenGL programmers need to know what the combination/final matrix is based on the known points on an object and their corresponding points on the viewport. I was just wondering if the issue had already been covered in this OpenGL group in an OpenGL fasion since the red book does not seem to have coverage on the issue.

Today is my 1st day to the forum and 1st post to the forum. Please forgive me if I asked a stupid question. Thank you all for sharing your knowledge and still appreciate any further comment.

Hi,

You might find some nice algorithms for this from the image-based rendering (search) community, this is a problem they deal with all the time.

-Ilkka