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

New plane split logic #27

Merged
merged 4 commits into from
Feb 4, 2019
Merged

New plane split logic #27

merged 4 commits into from
Feb 4, 2019

Conversation

kvark
Copy link
Member

@kvark kvark commented Feb 4, 2019

Fixes #26
This PR rewrites the logic of splitting a polygon by a line, deprecating the old function. The new one is robust against floating point inaccuracies, and handles the cases well when line intersection is very close to some of the vertices.

@kvark kvark requested a review from nical February 4, 2019 18:45
@kvark
Copy link
Member Author

kvark commented Feb 4, 2019

Looks good from limited local testing, waiting for Gecko try now: https://treeherder.mozilla.org/#/jobs?repo=try&selectedJob=225602367&revision=f546502f53b1bf032426ed54e79cbe87d83b6fe2

@kvark kvark requested a review from gw3583 February 4, 2019 18:45
Copy link
Contributor

@gw3583 gw3583 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't think in detail about the algorithm itself, but the general code changes seem fine. My only question is whether we need more tests for the various match conditions in split_impl ? Otherwise, r=me.

@kvark
Copy link
Member Author

kvark commented Feb 4, 2019

@gw3583 the tests for those cases where already in place, thankfully, so I don't expect any regressions. Thanks for taking a look!

@kvark
Copy link
Member Author

kvark commented Feb 4, 2019

Here is a brief description of the change:

Old algorithm

For each edge, intersect with the crossing line. if there are 2 edges with intersections, split the polygon. Problem here is that the intersection algorithm would produce discontinuous results around vertices, thus we were hitting issues whenever the intersection goes across a vertex closely.

New algorithm

Get the perpendicular vector to the cut, which happens to be the normal of the other intersection plane. Using this side vector, for each point figure out which side it's in, each side is represented by a floating point number. Where it crosses 0 is the edge for us to cut. So far, the process is continuous across the perimeter of the polygon. Once we figure out which edges to cut, we go into split_impl, which is shared with the old splitting code (but rewritten for better clarity).

@kvark kvark merged commit be5c980 into servo:master Feb 4, 2019
@kvark kvark deleted the new-cut branch February 4, 2019 19:51
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this pull request Feb 5, 2019
Update to have servo/plane-split#27 included

Differential Revision: https://phabricator.services.mozilla.com/D18593

--HG--
extra : moz-landing-system : lando
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this pull request Feb 5, 2019
Update to have servo/plane-split#27 included

Differential Revision: https://phabricator.services.mozilla.com/D18593

--HG--
extra : moz-landing-system : lando
mykmelez pushed a commit to mykmelez/gecko that referenced this pull request Feb 6, 2019
mykmelez pushed a commit to mykmelez/gecko that referenced this pull request Feb 6, 2019
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified that referenced this pull request Oct 3, 2019
Update to have servo/plane-split#27 included

Differential Revision: https://phabricator.services.mozilla.com/D18593

UltraBlame original commit: 553538a675ecaf39eebcaf54d6dce1e5d159cca0
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified that referenced this pull request Oct 3, 2019
Update to have servo/plane-split#27 included

Differential Revision: https://phabricator.services.mozilla.com/D18593

UltraBlame original commit: 2cbf16256f4ef5c0e234229ba5fb8840cdf04f4d
gecko-dev-updater pushed a commit to marco-c/gecko-dev-comments-removed that referenced this pull request Oct 3, 2019
Update to have servo/plane-split#27 included

Differential Revision: https://phabricator.services.mozilla.com/D18593

UltraBlame original commit: 553538a675ecaf39eebcaf54d6dce1e5d159cca0
gecko-dev-updater pushed a commit to marco-c/gecko-dev-comments-removed that referenced this pull request Oct 3, 2019
Update to have servo/plane-split#27 included

Differential Revision: https://phabricator.services.mozilla.com/D18593

UltraBlame original commit: 2cbf16256f4ef5c0e234229ba5fb8840cdf04f4d
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified-and-comments-removed that referenced this pull request Oct 4, 2019
Update to have servo/plane-split#27 included

Differential Revision: https://phabricator.services.mozilla.com/D18593

UltraBlame original commit: 553538a675ecaf39eebcaf54d6dce1e5d159cca0
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified-and-comments-removed that referenced this pull request Oct 4, 2019
Update to have servo/plane-split#27 included

Differential Revision: https://phabricator.services.mozilla.com/D18593

UltraBlame original commit: 2cbf16256f4ef5c0e234229ba5fb8840cdf04f4d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve quad-line intersection
2 participants