Ray - plane intersection

3.9k views Asked by At

I have the following problem that I am unable to solve, even after a long search on the internet.

How calculates the intersection of the plane in ray?

The plane is described by four points:

A (ax, ay, 0)
B (bx, by, 0)
C (cx, cy, 0)
D (dx, dy, 0)

Ray have:

Vector3f origin;
Vector3f direction;

And now, i want write a method for checking HIT. Could someone show me a solution?

public Boolean checkHit(Ray myRay){
.
.
.    
}

Thank you

1

There are 1 answers

0
John Alexiou On

A plane can be defined by a unit normal vector (nx,ny,nz) and a scalar distance from the origin d such that the equation of the plane is nx*x+ny*y+nz*z=d. You need to get the plane from 3 points to this format in order to proceed. If you don't know how you can look up finding a plane from three points.

Now the line can be specified by a unit direction vector (ex,ey,ez) and some point along the line (rx,ry,rz)

  1. Find the product s=(nx*ex+ny*ey+nz*ez). If it is zero then there is no intersection
  2. Find the distance of the intersection to the point on the line t=(d-(nx*rx+ny*ry+nz*rz))/s
  3. The intersection point is at c=(rx+ex*t, ry+ey*t, rz+ez*t)