#P2693. 3D Camera
3D Camera
Problem Description
Long long ago, there was a world of triangles. A smart guy in that world invented a camera, whose viewfinder was a
triangle. The camera's visual range could be represented by three RAYS. As the figure shows, the camera's visual
range could be represented by three rays OA, OB, OC. Note that the visual range is INFINITE.
Now, we have a camera with known visual range and a triangle DEF in the space. The inventor wants to know if the
camera can see the triangle, in other words, if there is at least one point of the triangle strict in the visual range.
Input
The input consists of multiple test cases. The first line of input contains an integer T, which is the number of test cases.
The first line of each test case contains 12 integers: Ox, Oy, Oz, Ax, Ay, Az, Bx, By, Bz, Cx, Cy, Cz. The second line
contains 9 integers: Dx, Dy, Dz, Ex, Ey, Ez, Fx, Fy, Fz.
All the integers in a line are separated by a whitespace.
[Technical Specification]
T is an integer, and T <= 1000.
The input guaranteed that if you look from O, three points ABC are always arranged counterclockwise.
All integers EXCEPT T is in the range of [-100,100].
We guarantee the camera and the triangle are not degenerate.
Output
For each test case, display a single line contains the result, "YES" for visible, "NO" for not visible.
2
90 -14 -17 71 98 94 69 59 -16 -52 68 13
-69 -96 43 81 -67 -79 66 -51 -53
0 0 1 0 0 0 1 0 0 0 1 0
0 0 -5 0 0 -6 1 1 -6
NO
YES