Problem Description
This is a simple problem. Given two triangles A and B, you should determine they are intersect, contain or disjoint. (Public edge or point are treated as intersect.)
Input
First line contains an integer T (1 ≤ T ≤ 10), represents there are T test cases.
For each test case: X1 Y1 X2 Y2 X3 Y3 X4 Y4 X5 Y5 X6 Y6. All the coordinate are integer. (X1,Y1) , (X2,Y2), (X3,Y3) forms triangles A ; (X4,Y4) , (X5,Y5), (X6,Y6) forms triangles B.
-10000<=All the coordinate <=10000
Output
For each test case, output “intersect”, “contain” or “disjoint”.
Sample Input
2 0 0 0 1 1 0 10 10 9 9 9 10 0 0 1 1 1 0 0 0 1 1 0 1
Sample Output
disjoint
intersect
判断两个三角形是 相交,包含,还是相离的关系
包含关系:
如图:若ΔDEF被包含;则可通过点来判断
D点被包含SΔACD+SΔCDB+SΔADB=SΔABC 同理判断E、F点,若三点全满足则包含
相离关系:
如图:若D点在外:则有SΔDAC+SΔDBC+SΔAB>SΔABC
若三点都满足上式,则相离,剩下的就只有相交关系了。
#include#include #include #include #include #include #include #include #include