No.622 Point Inside or Outside a Triangular Prism
Problem Statement
You are given 4 points A, B, C, D in 3-dimensional space. Consider the triangular prism obtained by extending triangle ABC in the direction perpendicular to the plane containing triangle ABC (plane ABC). Determine whether point D lies inside this prism. Of course, plane ABC is not necessarily parallel to the XY plane.
It is guaranteed that the distance between "the projection of point D onto plane ABC" and any side of triangle ABC is at least 0.01.
Input
$x_1$ $y_1$ $z_1$ $x_2$ $y_2$ $z_2$ $x_3$ $y_3$ $z_3$ $x_4$ $y_4$ $z_4$
$x_i,y_i,z_i: i(1 \le i \le 4)$-th point's $x$-coordinate, $y$-coordinate, $z$-coordinate (integers)
$-10^{6} \le x_i,y_i,z_i \le 10^6$
Output
Print YES if the point lies inside the triangular prism, and NO otherwise, on 1 line.
Do not print anything else.
Sample
Sample 1
Input
0 0 0 2 0 0 1 2 0 1 1 1
Output
YES
In this case, triangle ABC is parallel to the XY plane, so you can simply project point D onto the XY plane and perform a point-in-triangle test.
Sample 2
Input
3 0 0 0 3 0 0 0 3 1 1 9
Output
NO
In this case, triangle ABC is not parallel to the XY plane.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。
はむこ