• Advertisement
Sign in to follow this  

Reverse transform a point?

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm using a projection matrix to scale my game view according to window size. Though the mouse position needs to be reverse transformed from client space to game space. Is there a formula I can use?

Share this post


Link to post
Share on other sites
Advertisement
There's that little issue that a projection matrix doesn't have an inverse? ;)

To the OP, there is no way of reversing a projection of a point into a point because there are an infinite number of points (along a line) such that when projected would give you the mouse coordinate. the best that can be done is to get that line in 3d space and you'd have to do more work to produce the point in 3d space you want whether it be choosing the point at a certain distance (unlikely) or doing a ray cast on the scene geometry (probably more likely)

Share this post


Link to post
Share on other sites

There's that little issue that a projection matrix doesn't have an inverse? ;)

True that. I was thinking of the matrix that is often used for projection, which gives you a depth coordinate and is invertible. If you know the pixel where the mouse is and the corresponding depth (from a z-buffer, perhaps), you can just multiply by the inverse of that "projection" matrix.

But sure, what the OP is looking for might very well be what you described. A good name for a web search is "picking".

[EDIT: Typo]

Share this post


Link to post
Share on other sites

[quote name='luca-deltodesco' timestamp='1317892057' post='4869714']
There's that little issue that a projection matrix doesn't have an inverse? ;)

True that. I was thinking that the matrix that is often used for projection, which gives you a depth coordinate and is invertible. If you know the pixel where the mouse is and the corresponding depth (from a z-buffer, perhaps), you can just multiply by the inverse of that "projection" matrix.
[/quote]
The matrices used for projection in typical graphics APIs are fully and uniquely invertible.

The matrices are, arguably, not true projection matrices though, since they don't projection anything, only transform from one full-rank space to another equally ranked space. For example, a typical property of a projection is idempotence, which means that projecting an already projected point yields the same projected point. That is not true for the projection matrices commonly used by graphics APIs, which means that, arguably, they are not true projections.

By that definition, the depth buffer would not be possible if they were true projections, since the depth would be lost. One can argue that they are, in fact, projections, but with a preserved depth.

The problem here is not directly related to whether these matrices are actual projections or not, or whether a projection is invertible. The problem is only indirectly related to projection; it is not possible to uniquely reconstruct a third dimension given only two coordinates, which is what the original question appears to be about. Another piece of information is needed, like the Z-buffer value as you mentioned, at which point you have the three dimensions needed to uniquely undo the transformation.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement