Quote: "I'm actually referring to the 3D coordinates in space on a plane where x is any number and z is any number and y is 0."
Cool way to do this I learned from the tutorial "
vectors don't bite!"
global retx as float
global retz as float
function find_intersection(x as float, y as float)
null=make vector3(1)
null=make vector3(2)
null=make vector3(3)
set vector3 1,0,-1,0
pick screen x,y,1
set vector3 2,get pick vector x(), get pick vector y(), get pick vector z()
normalize vector3 3,2
scale vector3 2,3,camera position y()/dot product vector3(2, 1)
set vector3 1,camera position x(),camera position y(),camera position z()
add vector3 1,1,2
endfunction
lots of math, but it's really quite simple (well, dot product is a little hard to "get"). Basically, you have a right triangle in 3d space: From the camera's position, to the point of intersection with the plane, to the point at (camera x,0,camera z). We know the height of one side (camera y), and we know the direction from the camera's position to the point of intersection (this is the value returned by "get pick vector x/y/z". One can see that this direction multiplied by the hypotenuse of the triangle (which is the distance between the camera and the point of intersection), plus the camera's position is the point of intersection, so all we need to do is find the hypotenuse.
This is where dot product vector comes in. the pick vector is a unit vector pointing downwards. Since the side from the camera's position to (camera x,0,camera z) has a direction of (0,-1,0), we can find the cosine of the angle at the camera's position by taking the dot product of the pick vector and (0,-1,0). cosine=adjacent/hypotenuse, and adjacent=camera y, so hypotenuse=camera y/dot product(pick vector, (0,-1,0))
hypotenuse*pick vector + camera position = point of intersection.
Easy!