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 .