Anyone have source code or tips how to make function that finds out intersection point with line and plane in 3D space? We know line's start point and direction vectors and also position and normal vector for plane.
This is what i have come up with but it doesn't work when i move either line or plane from 0,0,0 point.
[pascal]function Dot(const a,b: P3f): single;
result:=a.x*b.x + a.y*b.y + a.z*b.z;
function vDec(const a,b: P3f): P3f;
result.x:=a.x-b.x; result.y:=a.y-b.y; result.z:=a.z-b.z;
procedure rayPlaneCollision(const rayOrigin, rayDirection,
planeOrigin, planeNormal: P3f; intersection: pP3f);
var u,d: single;
if d=0 then exit; // No intersection
Update: It does work when planeOrigin and rayorigin are at exact same (anywhere) point, but that is cheating because that is also the same as intersection point.