code: public static double distanceFromLine(double x0, double y0, double x1, double y1, double x2, double y2)
      {
          double dx = x2-x1;
          if (dx == 0.0)
          {
              return Math.abs(x1-x0);
          }
          double dy = y2-y1;
          if (dy == 0.0)
          {
              return Math.abs(y1-y0);
          }
          return Math.abs(dy*x0-dx*y0+x2*y1-y2*x1)/Math.hypot(dx, dy);
      }
docs: Returns distance from point (x0, y0) to line that goes through points
  (x1, y1) and (x2, y2)
  @param x0
  @param y0
  @param x1
  @param y1
  @param x2
  @param y2
  @return