iâ€™m trying to get the coordinates of a point in an image.
letâ€™s say i know the point i need to know itâ€™s coordinates after a translation and rotation, but i know the coordinates before the transformation and i would like to know where this point has gone after the transformations â€¦

iâ€™ve seen some related posts on the forum but i didnâ€™t figure it out â€¦ in pseudo-code.

ofPushMatrix()
ofPoint p;
// that's the point i want to know the coordinates
p.set(px,py);
ofTranslate(t);
ofRotation(r,0,0,1);
ofTranslate(-t);
// here i would like to know where my point p has gone ?
// where has p ben transformed to ?

Iâ€™ve tried getting the matrix after all the transformations

and then trying to mulitply the point by the matrix i got before â€¦

ofPushMatrix();
p = p*mat ;

But the result i got itâ€™s not where it should â€¦

Can anyone understand what iâ€™m trying to express and solve ?
I tried inverting the matrix point multiplication â€¦ but again the result itâ€™s not correct.

You can check the ofNode class, it has functions showing exactly what you need. It represents a transform, including position (point) rotation and scale.

Also, I think you need to get modelview * projection matrix in order to get that multiplication right. There might be a more direct method in OF that I donâ€™t know of

so i should create a ofNode on the point iâ€™m interested on before transform â€¦
then apply the same transformation iâ€™m doing to the image, but to the ofNode
and then calling getGlobalPosition on the node ?

is that the idea ? iâ€™ve never used ofNode with such functions â€¦
by the way iâ€™m multiplying with the modelview matrix as you suggested in the call :
glGetFloatv( GL_MODELVIEW_MATRIX, myMatrix );
on my pseudo-code â€¦

iâ€™ll give it a try !! thanks a lot for the path !!

the problem I think is that the translations that the camera is doing are baked into the mat at this point. If you look at the GL_MODELVIEW_MATRIX at the start of the draw call, youâ€™ll see this is the case. for example, I have a small window 400x200, mat looks like this at the start:

thanks for your idea of keeping a matrix with all the transformation commands on it â€¦ just works !
i assume that the reason why getting the GL_MODELVIEW_MATRIX straight on is that

the translations that the camera is doing are baked into the mat at this point.

I thought that it was possible to query opengl for the matrix that keeps all the transformations, without any relation to camera â€¦ anyway â€¦ your solution works !

@chuckleplant i didnâ€™t find a way of working it out with the ofNode approach â€¦ ofNode::GetGlobalPosition() seems to donâ€™t do what i expected â€¦ as it seems that getGlobalPosition is not taking in consideration the scale o the node so the coordinates are not as i expected. (iâ€™m doing just a scale and rotation over Z).

by the way iâ€™m not on a 3D space â€¦ just 2D .
many many thanks â€¦ allways learning .