I've been thinking about this question for a quite long time.And my implementation seems to be correct for some cases but wrong with few others.
How can I comprehensive test the algorithm? Is there any provided test cases?
Computer Graphics Stack Exchange is a question and answer site for computer graphics researchers and programmers. It only takes a minute to sign up.
Sign up to join this communityI've been thinking about this question for a quite long time.And my implementation seems to be correct for some cases but wrong with few others.
How can I comprehensive test the algorithm? Is there any provided test cases?
The way of detecting intersection is two steps. (I referred to http://www-bcf.usc.edu/~jbarbic/cs420-s18/runuscedu/cs420-s18/16-geometric-queries/16-geometric-queries-6up.pdf)
Let's suppose the start point of the ray $R$ is $(x_0, y_0, z_0)$ and direction is $(x_d, y_d, z_d)$, then $R = (x_0, y_0, z_0) + (x_d, y_d, z_d)t$ , and the plane is $ax + by + cz + d = 0$.
To check intersection between the ray and plane, calculate the below equation.
$t = \frac{-(ax_0 + by_0 + cz_0 + d)}{ax_d + by_d + cz+d}$
If $t \ge 0$, then there is a possibility of intersection, so go second step.
else there is not intersection.
Since $t \ge 0 $, we know the point on the plane.
Hnece, we can get the $\alpha, \beta, \gamma$.
If $0 \le\alpha, \beta, \gamma \le 1$ and $\alpha+ \beta + \gamma = 1$, then there is intersecton.
else No intersection!.
(The page 19, 20 is explaining how to calculate the 'Area'. (Actually, we can project the 3D space points to 2D space for performance, but avoid the perpendicular projection!) )