Hannibal is on a mission. He has to shoot a criminal. Hannibal was on the point (0, 0) and the criminal is on the point (Xc, Yc). But there is a wall between the point (X1, Y1) and (X2, Y2). You have to tell whether Hannibal can shoot criminal or not. INPUT: First line contains the total number of test cases T. For each test case, a single line contains space separated integers denoting X1, Y1, X2, Y2, Xc, Yc. OUTPUT: For each test case display YES, if Hannibal can shoot the criminal. Otherwise, display NO. Constraints: 1 <= T <= 100 1 <= X, Y <= 1000000 Sample Input
@Algorithmic
Hanibal can shoot the criminal: |dw:1434191219837:dw| Hanibal cannot shoot the criminal: |dw:1434191688599:dw| There are several approaches to this; two of them are: 1. You the treat wall and bullet path as lines (calculate mx+b) and see if they intersect on the given intervals. 2. You treat wall and bullet path as line segments and use linear algebra find whether they intersect or not. This one is a bit tricky but a lot of resources are available on the web (i.e. http://stackoverflow.com/questions/563198/how-do-you-detect-where-two-line-segments-intersect )
Join our real-time social learning platform and learn together with your friends!