Closed robertkovacs closed 4 years ago
Hi @robertkovacs. I was unable to reproduce this.
const geometric = require("geometric");
const a = [[180, 140], [180, 205]],
b = [[160, 180], [170, 181.72], [180, 187.64], [185, 193.41]];
console.log(geometric.polygonIntersectsPolygon(a, b)); // true
console.log(geometric.polygonIntersectsPolygon(b, a)); // true
I've also added it to the test suite: https://github.com/HarryStevens/geometric/blob/master/test/polygonIntersectsPolygon-test.js#L40
geometric.polygonIntersectsPolygon also returns true if two overlapping rectangles share two edges.
@HarryStevens Can you guide me in this case? I want the function above return false if they share two edges. What should I do?
geometric.polygonIntersectsPolygon also returns true if two overlapping rectangles share two edges.
@HarryStevens Can you guide me in this case? I want the function above return false if they share two edges. What should I do?
I can't picture this. What it would it look like for two rectangles to share two edges but not overlap?
On Mon, 1 Nov 2021 at 03:55 Harry Stevens @.***> wrote:
geometric.polygonIntersectsPolygon also returns true if two overlapping rectangles share two edges. @HarryStevens https://github.com/HarryStevens Can you guide me in this case? I want the function above return false if they share two edges. What should I do?
I can't picture this. What it would it look like for two rectangles to share two edges but not overlap?
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/HarryStevens/geometric/issues/13#issuecomment-955790038, or unsubscribe https://github.com/notifications/unsubscribe-auth/AC277TGTRTTZTQMWAQ5FE43UJWUMNANCNFSM4NHIVDKQ .
Yes they share edges but not overlap--
I don't think that is possible. Can you show me a picture of what you mean?
In version 2.2.1, using the following two polygons:
[[180, 140], [180, 205]] and
[[160, 180], [170, 181.72], [180, 187.64], [185, 193.41]]
'polygonIntersectsPolygon' gives false, though these two polygons clearly do intersect. The problem is in the 'lineIntersectsLine' function, where replacing the original
return 0 < lambda && lambda < 1 && 0 < gamma && gamma < 1;
line by
return 0 <= lambda && lambda <= 1 && 0 <= gamma && gamma <= 1;
allows detecting 'endpoint intersections'.
With this modification the 'polygonIntersectsPolygon' function gives a correct result.
Tested in Safari Version 13.1 (15609.1.20.111.8).