Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Difference fails with overlapping edges #81

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Difference fails with overlapping edges #81

wants to merge 2 commits into from

Conversation

w8r
Copy link
Owner

@w8r w8r commented May 27, 2018

#80

@w8r
Copy link
Owner Author

w8r commented May 27, 2018

@mfogel does this work in your version?

@mfogel
Copy link
Contributor

mfogel commented May 28, 2018

Yeah, it does.

> subject = [[[10, 10], [80, 10], [80, 80], [10, 80], [10, 10]]]
[ [ [ 10, 10 ], [ 80, 10 ], [ 80, 80 ], [ 10, 80 ], [ 10, 10 ] ] ]
> clipping = [[[20, 10], [30, 10], [30, 80], [20, 80], [20, 10]]]
[ [ [ 20, 10 ], [ 30, 10 ], [ 30, 80 ], [ 20, 80 ], [ 20, 10 ] ] ]
> result = polygonClipping.difference(subject, clipping)
[ [ [ [Array], [Array], [Array], [Array], [Array] ] ],
  [ [ [Array], [Array], [Array], [Array], [Array] ] ] ]
> result[0]
[ [ [ 10, 10 ], [ 20, 10 ], [ 20, 80 ], [ 10, 80 ], [ 10, 10 ] ] ]
> result[1]
[ [ [ 30, 10 ], [ 80, 10 ], [ 80, 80 ], [ 30, 80 ], [ 30, 10 ] ] ]

@w8r
Copy link
Owner Author

w8r commented May 28, 2018

@mfogel thanks!

@HansonYip
Copy link

HansonYip commented Jan 5, 2019

I also found a similar problem about shared edge.

var p1 = [[[0,0],[2,2],[4,2],[2,0],[0,0]]];
var p2 = [[[1,0],[2,1],[3,1],[2,0],[1,0]]];
var differenced = difference(p1, p2);

But the result is

[[[[0,0],[1,0],[2,0],[2,1],[3,1],[4,2],[2,2],[0,0]]]]

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants