If I have two java.awt.geom.Area made from a union of various simple shapes (polygons and ellipses), is there a way to find the distance (i.e. the closest distance) between the two areas?
To clarify: suppose I have two arbitrary areas, each of which is created from a union of any form:
//Define the first area Area a = new Area(new Ellipse2D.Double(50, 50, 100, 100)); a.add(new Area(new Rectangle2D.Double(100, 100, 100, 100))); //Define the second area Area b = new Area(new Ellipse2D.Double(200, 300, 100, 100)); b.add(new Area(new Ellipse2D.Double(250, 250, 100, 100)));
What I want is the getDistance(Area a, Area b) method, which gives me a double view representing the shortest distance between any point in area a and any point in area b. Here's an image of the two above areas with a blue line indicating the distance I'm interested in:

Is there any way to do this? If not, how can I implement one?
source share