以下のコードは問題を部分的に解決しましたが、この部分は頂点でのみ機能するため、他のポリゴンにより近いエッジ上のポイントを検出することで拡張する必要があります。
static double solve(List<List<Integer>> p, List<List<Integer>> q) {
double minLength = 100000000;
for (List<Integer> qq : q) {
for (List<Integer> pp : p) {
double current = distanceBTWPoints(pp, qq);
if (current < minLength) {
minLength = current;
}
}
}
System.out.println(minLength);
return minLength;
}
static double distanceBTWPoints(List<Integer> p, List<Integer> q) {
double xDiff = q.get(0) - p.get(0);
double yDiff = q.get(1) - p.get(1);
// if(xDiff==0 || yDiff==0)
// return 0;
System.out.println(+p.get(0) + " " + q.get(0) + " " + p.get(1) + " " + q.get(1) + " x:" + xDiff + " y: " + yDiff + " p: " + ((xDiff * xDiff) + (yDiff * yDiff)) + " VAl= " + Math.sqrt((xDiff * xDiff) + (yDiff * yDiff)));
// System.out.println("p.get(0): "+p.get(0) +" q.get(0) :"+q.get(0) +" p.get(1): "+p.get(1) +" q.get(1): "+q.get(1) +" xDiff: " + xDiff + " yDiff: " + yDiff + " plus: "+((xDiff * xDiff) + (yDiff * yDiff))+ " VAl= " + Math.sqrt((xDiff * xDiff) + (yDiff * yDiff)));
System.out.println("--" + Math.hypot(xDiff, yDiff));
System.out.println("--" + Math.sqrt((xDiff * xDiff) + (yDiff * yDiff)));
return Math.hypot(xDiff, yDiff);
}