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

BooleanOperations.intersect(a, b) doesn't seem to return correct results #50

Closed
anvaka opened this issue Jul 10, 2020 · 2 comments
Closed
Labels

Comments

@anvaka
Copy link

anvaka commented Jul 10, 2020

Here is an observable notebook to play: https://observablehq.com/d/adead0595ff39aa7

  let {point, BooleanOperations, Polygon} = Flatten;  
  // Create new polygon
  let a = new Polygon([
    point(10,10), 
    point(10, 100),
    point(100, 100), 
    point(100, 10), 
  ]);
  let b = new Polygon([
    point(90,50), 
    point(120, 10),
    point(120, 100)
  ]);
  
  let stage = d3.select(DOM.svg(400, 400));
  stage.html(a.svg() + b.svg() + BooleanOperations.intersect(a, b).svg({fill: 'red'})); 

I expect the intersection to be there, but seems like return path is empty:

image

@alexbol99
Copy link
Owner

Hello @anvaka ,

Polygons in boolean operation should have same orientation.
You can ensure this by adding check like following:

if ([...a.faces][0].orientation() != [...b.faces][0].orientation()) {
    a = a.reverse()
}

Then you will get expected result.

Best,
Alex

@anvaka
Copy link
Author

anvaka commented Jul 17, 2020

That was it. Thank you!

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

No branches or pull requests

2 participants