java.awt.geom.Area中的相交无法正常工作

时间:2017-09-21 15:28:24

标签: java geometry

我目前正在尝试计算2 Path2D的交集以便这样做我正在使用以下函数:

*private boolean pathOverlaps(Path2D path1, Path2D path2) { 
        Area a1 = new Area(path1);
        Area a2 = new Area(path2);
        a1.intersect(a2);
        return !a1.isEmpty();   
    }*

这适用于大多数情况但不是全部...使用这些Path2D,它相交会返回false,我不明白为什么。 下面是2 Path2D的点,当在pathOverlaps函数中使用时返回意外的结果,它们应该相交,但是否则返回......

路径1: 80.19948186528497 -49.90291262135922 80.19948186528497 -48.0 82.14766839378238 -48.0 82.14766839378238 -48.0 82.14766839378238 8.135922330097088 80.19948186528497 8.135922330097088 80.19948186528497 10.038834951456312 80.19948186528497 10.038834951456312 65.880310880829 10.038834951456312 65.880310880829 10.990291262135925 64.9062176165803 10.990291262135925 64.9062176165803 10.990291262135925 64.9062176165803 46.19417475728156 62.95803108808289 46.19417475728156 62.95803108808289 48.09708737864078 62.95803108808289 48.09708737864078 -103.90414507772022 48.09708737864078 -103.90414507772022 46.19417475728156 -105.85233160621763 46.19417475728156 -105.85233160621763 46.19417475728156 -105.85233160621763 -48.0 -103.90414507772022 -48.0 -103.90414507772022 -49.90291262135922 -103.90414507772022 -49.90291262135922 -107.0 -52.5 -107.0 -52.5 -107.0 -50.5 -109.0 -50.5 -109.0 48.5 -109.0 48.5 -107.0 48.5 -107.0 50.5 64.3 50.5 64.3 50.5 64.3 48.5 66.3 48.5 66.3 11.5 66.3 11.5 67.3 11.5 67.3 10.5 82.0 10.5 82.0 10.5 82.0 8.5 84.0 8.5 84.0 -50.5 84.0 -50.5 82.0 -50.5 82.0 -52.5

路径2: 82.10000000000001 -24-24.625 82.10000000000001 -24-24.01748677518613 81.60751322481389 -24-23.525 81.0 -24-23.525 80.39248677518613 -24-23.525 79.9 -24-24.01748677518613 79.9 -24-24.625 79.9 -24-25.232513224813875 80.39248677518613 -24-25.725 81.0 -24-25.725 81.60751322481389 -24-25.725 82.10000000000001 -24-25.232513224813875 82.10000000000001 -24-24.625

谢谢。

0 个答案:

没有答案
相关问题