且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Java中两个形状/区域之间的距离?

更新时间:2023-02-01 23:12:00

似乎没有一种方法可以准确地做到这一点.但是,使用PathIterator s,您应该能够沿形状轮廓进行点对点比较并手动找到距离.

There doesn't seem to be a method that does that exactly; however, using PathIterators, you should be able to compare point to point along the outline of the shapes and find the distance manually.

http://docs.oracle. com/javase/6/docs/api/java/awt/geom/PathIterator.html

这篇Wikipedia文章介绍了如何有效实施这样可以避免二次明显的实现.

This Wikipedia article describes how you could efficiently implement this to avoid the quadratic obvious implementation.