bg::intersection result is the second input polygon instead of empty polygon

Open
#1,201 1 comment 0 reactions 1 assignee View on GitHub

Maintainers usually reply within 2 days

@barendgehrels is already working on this.

Since Nov 24, 2024.

Assessment

This issue has not been assessed yet.

Description

on version 1.83 the bg::Intersection generates wrong result for this specific case. The result polygon is same as the second input polygon Q.
When the first polygon P has instead of the value 1e-14 eg. 1e-13 or 1e-15, the result is empty, which is correct.

using boost_point_2d = boost::geometry::model::d2::point_xy;
using boost_polygon_2d = boost::geometry::model::polygon<boost_point_2d, false>;
using boost_multipolygon_2d = boost::geometry::model::multi_polygon<boost_polygon_2d>;

boost_polygon_2d P = {{{1e-14, 0}, {-10, 50}, {-20, 50}, {1e-14, 0}}};
boost_polygon_2d Q = {{{0, 1000}, {0, 0}, {1000, 0}, {1000, 1000}, {0, 1000}}};
boost_multipolygon_2d R;

bg::intersection(P, Q, R);
image

Dominant language
C++
Stars
519
Forks
241
Avg merge
4d 15h
Merged PRs (30d)
9

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from boostorg/geometry

All issues in boostorg/geometry

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.