0
votes

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
@SlySherZ Thank you for your reply (the link I've seen), but I do not understand it and I am not able to apply to my problem.stoudrae
You know three points define a plane, not four.John Alexiou
i kow, but ho can i write it?stoudrae
Also in the most general case az, bz, cz and dz are not zero. You would have to choose three of the four points to define one plane, and then another three for the next plane.John Alexiou

1 Answers

1
votes

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)