# How to determine clicked world coordinates?

So, the guys on the coding side told me to drop by here with this...

I am rendering a world using LWJGL, and what I need to find out are the x, y and z coordinates of the block that the player clicks on their screen. Player position in all three dimensions is known, as is the camera distance and angle, both relative to ground and to the player's orientation. Screen width and height are known, and the mouse x and y coordinates are called when the player clicks. The size of each block/cube used as a part of the 3D world is relative to the screen's size.

Thanks for your help.

Edit: Uhm... trying to pose this question more mathematically just made me realize that I just can't. I'll try and go ask on the coding side again.

• I am afraid your question is not understandable for the uninitiated. So you have some kind of 3d world and need 3 coordinates of something? What exactly is given, and what is missing? Maybe phrasing this a bit more mathematically/formally would help us to understand where you are stuck. Thanks. – Nameless Nov 21 '13 at 0:21

The 2D screen is some kind of plane in your 3D world, which you can compute using camera position and angle (it's perpendicular to your viewing direction). The mouse $x$ and $y$ convert to a point on this plane. Now create a half-line from your camera to this point and find the nearest intersection point with your set of blocks. Check some computational geometry book for good data structures so you can find this block fast.