Intersectionpoint of plane and ray


i have two vectors (points), that lay on a ray, and a plane. I have the planes normal and its distance. Now i need to calculate where the ray intersects the plane.
I know how i would do it in school, but i cannot use this algorithm in a program. And i just can´t get the solution how to program it.

I would really appreciate, if someone can help me.


Let A and B be the two points on your ray. Then RV=B-A is the ray vector and RO=A is the ray origin. PN is the plane normal and PD is the distance from the origin to your plane in PN units. If D=RV[dot]PN is zero there is no intersection else I=RO+RV*(RD-(RO[dot]PN))/D. I is your intersection point. Try this or visit !

P1 and P2 are a point of ray.
Pa,Pb,Pc are points of plane.
Ax+By+Cz+D = plane equation…
A,B,C = normal of plane(try use cross product)
then u can get D from the equation of plane…
Try to put the p1 and p2 to a plane equation
and u will get a value (distance1 and distance2)…
no intersection