I have two arbitrary shape. Now I want to calculate the minimum distance between two shapes. Here I am attaching the image
First of all draw part is completed. This Shapes are combination of Arc and line. Now I am facing problem when I am going to calculate the minimum distance between this shapes. Draw this shapes using GWT (java) html5 canvas.
For calculating minimum distance between two shape I have used below code in java but I am not getting any optimized way to do that -
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;
}
coordinates_1 contains the collection of points of shape-1.
coordinates_2 contains the collection of points of shape-2.
Is there any optimized way to calculate the distance between two shape? This shapes are could be any where and any type of shapes.
Instead of calculating the minimum distance between two set of point we can do it in optimized way by calculating distance between line to line or line to arc or arc to arc. In this way we can calculate the minimum distance in optimized way.