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

Fix line trim when line begins on polygon edge #356

Merged
merged 4 commits into from
Jul 31, 2020

Conversation

andrewheumann
Copy link
Member

@andrewheumann andrewheumann commented Jul 31, 2020

BACKGROUND:

DESCRIPTION:

  • Add a better check for whether the line begins outside the polygon
  • double-check containment in ambiguous cases

TESTING:

  • added TrimLineThatStartsAtPolygonEdge() test, this failed with the old method, succeeds now
  • tested on a large range of other conditions similar to the reported case

This change is Reviewable

@andrewheumann andrewheumann requested a review from ikeough July 31, 2020 13:12
Copy link
Contributor

@ikeough ikeough left a comment

Choose a reason for hiding this comment

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

Reviewable status: 0 of 5 files reviewed, 1 unresolved discussion (waiting on @andrewheumann and @ikeough)


src/Elements/Geometry/Line.cs, line 472 at r1 (raw file):

            // Add the segment's starting point.
            intersections.Add(this.Start);
            polygon.Contains(this.Start, out var containment);

Are we going to have a similar problem if the line ends on the polygon as well?

Copy link
Member Author

@andrewheumann andrewheumann left a comment

Choose a reason for hiding this comment

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

Reviewable status: 0 of 5 files reviewed, 1 unresolved discussion (waiting on @ikeough)


src/Elements/Geometry/Line.cs, line 472 at r1 (raw file):

Previously, ikeough (Ian Keough) wrote…

Are we going to have a similar problem if the line ends on the polygon as well?

No — it splits the line at all the intersections and alternates its way down from the start to the end. It only matters whether it starts inside or outside.

Copy link
Contributor

@ikeough ikeough left a comment

Choose a reason for hiding this comment

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

Reviewable status: 0 of 5 files reviewed, all discussions resolved

@andrewheumann andrewheumann merged commit be70998 into hypar-io:master Jul 31, 2020
@andrewheumann andrewheumann deleted the fix-line-trim branch July 31, 2020 15:47
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.

Line.Trim(Polygon) does not trim correctly with concave polygons.
2 participants