code: public HitResult intersect(Shape shape, Line line) {
  		float distance = Float.MAX_VALUE;
  		HitResult hit = null;
  		
  		for (int i=0;i<shape.getPointCount();i++) {
  			int next = rationalPoint(shape, i+1);
  			Line local = getLine(shape, i, next);
  		
  			Vector2f pt = line.intersect(local, true);
  			if (pt != null) {
  				float newDis = pt.distance(line.getStart());
  				if ((newDis < distance) && (newDis > EPSILON)) {
  					hit = new HitResult();
  					hit.pt = pt;
  					hit.line = local;
  					hit.p1 = i;
  					hit.p2 = next;
  					distance = newDis;
  				}
  			}
  		}
  		
  		return hit;
  	}
docs: Intersect a line with a shape
  
  @param shape The shape to compare
  @param line The line to intersect against the shape
  @return The result describing the intersection or null if none