I programmed the same thing as the link they gave you, so I might be able to help explain it.

as you know a line can be represented mathematically in two ways.
1- two points
2- a point and a direction

planes work the same way and they can also be calculated in two ways.
1- three points
2- a point and a normal

This information is only nneded to calculate it mathematically, you don't need a real phisical line, and you dont need a real phisical terrain either.


In his funtion he is using as input for the line the first method (two points), and for the imput to calculate the plane he is using the second method (a point and a normal).
-to give the inputs for the line you just need to give the function any two points on the line. for example (in your case) transforming the cursor's screen coords to the 3d view with a depth of 1, and transforming the cursor coords again to 3d coords with a depth of 2.
-to give the inputs for the plane you need to give it ANY point that is ON the imaginary plane, and the imaginary plane's normal. for example (in your case) if you wanted the plane to be at a height of z=0 you can give it any point on that plane. that means that you could pass any value for x and any value for y as long as you passed 0 for the z value (since all points with z=0 would be on that imaginary plane's surface).
For the normal you would give 0,0,1 if you want your plane's surface to be horizontal since that would mean it's surface normal would be pointing upwards.

You only need the values of this imaginary line and the imaginary plane so he can calucate it mathematically, you do not need to have them phisically loaded.

the output will be either a coordinate where they intersect, or NULL if the line is parallel to the plane (because then it never intersects with our imaginary plane).

How the function does this is irrelevant but if you wish to know... with the two vectors of the line it calculates the formula that defines that line, and with the point and normal for the plane it calculates the formula that will define that plane. then it simply plugs the values for one formula into the other formula and the result is the intersection of both. If you want to achieve this yourself you can read about it in any basic calculus book to learn how to create a formula that defines a line, how to create the formula that defines a plane, and how to calculate the intersection of both.

If you wish to learn in a more visual way, follow the links below for an online video demonstration:
LINES: http://www.youtube.com/watch?v=GFM8NOe_XM4
PLANES: http://www.youtube.com/watch?v=3QLaud6SnHM
INTERSECTIONS: http://www.youtube.com/watch?v=-_DStDQffQo

and here is the best (and most detailed) video I found on this subject. This video covers everything from 2d line equations and the basic concepts of planes, all the way to the more complex stuff you can do with this in 3d (like line and plane intersections).
http://www.youtube.com/watch?v=Q0gnrV699GQ
in my opinion this last video is a must-watch for anyone programming in 2d/3d
Hope I helped ;D


"The more you know, the more you realize how little you know..."

I <3 HORUS
http://www.opserver.de/ubb7/ubbthreads.php?ubb=showflat&Number=401929&page=1