I have two arbitrary forms. Now I want to calculate the minimum distance between two shapes. Here I attach the image

First of all, the part is completed. These shapes are a combination of an arc and a line. Now I am faced with a problem when I am going to calculate the minimum distance between these figures. Draw these shapes using the GWT (java) html5 canvas.
To calculate the minimum distance between two forms, I used below code in java, but I don't get an optimized way to do this -
private double calculateMinimumDistance(Coordinate[] coordinates_1, Coordinate[] coordinates_2) {
double minDistance = 100000;
double currentDistance = 0;
for(int i = 0; i < coordinates_1.length; ++i) {
for(int j = 0; j < coordinates_2.length; ++j) {
currentDistance = coordinates_1[i].distanceTo(coordinates_2[j]);
if(currentDistance < minDistance) {
minDistance = currentDistance;
}
}
}
return minDistance;
}
codes_1 contains a set of form-1 points.
Coordinates_2 contain a set of points of the form-2.
Is there an optimized way to calculate the distance between two shapes? This shape can be any, where and any type of figures.
, . , .