+2  A: 

General solution of the itnersection of a line and a plane see http://local.wasp.uwa.edu.au/~pbourke/geometry/planeline/

Your particular graphics lib (OpenGL/DirectcX etc) may have an standard way to do this

edit: You are trying to find the 3d intersection of a screen point (eg a mouse cursor) with a 3d object in you scene?

Martin Beckett
I am not trying to find the intersection of a line and a plane. I am actually trying to generate the line. That is, the second end-point of the line is un-known and that's what I'm trying to solve for. The "viewing plane" is just terminology. It's not actually a plane (since a plane extends infinitely in all directions). Rather this "plane" has fixed dimension and I am trying to figure out the 3D coordinates of each of the points on the plane (the points on the plane range from 0 to width in the x direction and 0 to height in the y direction)
Myx
That's what these algorithms achieve. You can identify the polygons that are represented in a pixel, as well as the barycentric coordinates *within* it.
greyfade
I don't understand what you mean. The "pixel" is simply an (i,j) position...
Myx
A: 

To work out P, you need the distance from the camera to the near clipping plane (the screen), the size of the window on the near clipping plane (or the view angle, you can work out the window size from the view angle) and the size of the rendered window.

  1. Scale the screen position to the range -1 < x < +1 and -1 < y < +1 where +1 is the top/right and -1 is the bottom/left
  2. Scale normalised x,y by the view window size
  3. Scale by the right and up vectors of the camera and sum the results
  4. Add the look at vector scaled by the clipping plane distance

In effect, you get:

p = at * near_clip_dist + x * right + y * up

where x and y are:

x = (screen_x - screen_centre_x) / (width / 2) * view_width
y = (screen_y - screen_centre_y) / (height / 2) * view_height
Skizz
what's the difference between view_width and width?
Myx
@Myx: width is the screen width, usually in pixels. view_width is the width, in world co-ordinates, of the window positioned at the near clip plane through which the camera looks.
Skizz
A: 

When I directly plugged in suggested formulas into my program, I didn't obtain correct results (maybe some debugging needed to be done). My initial problem seemed to be in the misunderstanding of the (x,y,z) coordinates of the interpolating corner points. I was treating x,y,z-coordinates separately, where I should not (and this may be specific to the application, since the camera can be oriented in any direction). Instead, the solution turned out to be a simple interpolation of the corner points of the viewing plane:

  • interpolate the bottom corner points in the i direction to get P1
  • interpolate the top corner points in the i direction to get P2
  • interpolate P1 and P2 in the j direction to get the world coordinates of the final point
Myx