class Tools2D{

  static int area2(Point2D A, Point2D B, Point2D C){
    int x =  (A.x - C.x) * (B.y - C.y) - (A.y - C.y) * (B.x - C.x);
    System.out.println("RESULT: "+x);
    return x;
  }
 
  static boolean insideTriangle(Point2D A, Point2D B, Point2D C, Point2D P){
    boolean inside = 
      Tools2D.area2(A, B, P) >= 0 &&
      Tools2D.area2(B, C, P) >= 0 &&
      Tools2D.area2(C, A, P) >=0;
    System.out.println("---------------");
    return inside;
  }

  static boolean insidePolygon(Point2D P, Point2D[] pol){
    int n = pol.length, j = n - 1;
    boolean b = false;
    float x = P.x, y = P.y;
    for(int i = 0; i<n; i++){
      if(pol[j].y <= y && y < pol[i].y &&
      Tools2D.area2(pol[i], pol[j], P) > 0 ||
      pol[i].y <= y && y < pol[j].y &&
      Tools2D.area2(pol[j], pol[i], P) > 0 ) b = !b;
      j = i;
    }
    return b;
  }

}
