# Obtaining a world point from a screen point with an orthographic projection

I assumed this was a straightforward problem but it has been plaguing me for days.

I am creating a 2D game with an orthographic camera. I am using a 3D camera rather than just hacking it because I want to support rotating, panning, and zooming. Unfortunately the math overwhelms me when I'm trying to figure out how to determine if a clicked point intersects a bounds (let's say rectangular) in the game.

I was under the impression that I could simply transform the screen point (the clicked point) by the inverse of the camera's View * Projection matrix to obtain the world coordinates of the clicked point. Unfortunately this is not the case at all; I get some point that seems to be in some completely different coordinate system.

So then as a sanity check I tried taking an arbitrary world point and transforming it by the camera's View*Projection matrices. Surely this should get me the corresponding screen point, but even that didn't work, and it is quickly shattering any illusion I had that I understood 3D coordinate systems and the math involved.

So, if I could form this into a question: How would I use my camera's state information (view and projection matrices, for instance) to transform a world point to a screen point, and vice versa? I hope the problem will be simpler since I'm using an orthographic camera and can make several assumptions from that.

I very much appreciate any help. If it makes a difference, I'm using XNA Game Studio.

• I should add that the camera I'm using works perfectly well for the purposes of drawing. The rotation, panning and zooming works exactly as expected. I'm using SpriteBatch with a custom BasicEffect parameter and setting the BasicEffect's View and Projection matrices to the corresponding camera transforms. Commented Jan 4, 2011 at 9:58

//conversion from pixel values to unit cube (result of projection)

screenPoint.Z defines distance from camera 0.0 = znear, 1.0 = zfar. As you are making 2D game, you dont care about it propably.
screenPoint.W have to be 1.0