code: public static int relativeCCW (double px, double py, double x1, double y1, double x2, double y2) {
          // A = (x2-x1, y2-y1)
          // P = (px-x1, py-y1)
          x2 -= x1;
          y2 -= y1;
          px -= x1;
          py -= y1;
          double t = px * y2 - py * x2; // PxA
          if (t == 0f) {
              t = px * x2 + py * y2; // P*A
              if (t > 0f) {
                  px -= x2; // B-A
                  py -= y2;
                  t = px * x2 + py * y2; // (P-A)*A
                  if (t < 0f) {
                      t = 0f;
                  }
              }
          }
          return (t < 0f) ? -1 : (t > 0f ? 1 : 0);
      }
docs: Returns an indicator of where the specified point (px,py) lies with respect to the line
  segment from (x1,y1) to (x2,y2).
  
  See http://download.oracle.com/javase/6/docs/api/java/awt/geom/Line2D.html