Skip to content

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.

4 participants