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

use orientation for line intersection #32

Merged
merged 6 commits into from
Aug 30, 2019
Merged

use orientation for line intersection #32

merged 6 commits into from
Aug 30, 2019

Conversation

den3tsou
Copy link
Collaborator

No description provided.

@den3tsou den3tsou self-assigned this Aug 16, 2019
o3 := orientation(c, d, a)
o4 := orientation(c, d, b)

if o1 != o2 &&
Copy link
Owner

Choose a reason for hiding this comment

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

This if statement used to be for the case where the two line segments are parallel. Is that still true? If so, then would if o1 == collinear && o2 == collinear { suffice as the condition?

if abBB.max.X.Equals(cdBB.min.X) && abBB.min.Y.Equals(cdBB.max.Y) {
// Line segments overlap at a point.
return NewPointS(abBB.max.X, abBB.min.Y)
if o1 != o2 && o3 != o4 {
Copy link
Owner

Choose a reason for hiding this comment

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

Can you add a comment explaining what cases each of the 3 main if statements cover? It's a real brain strain trying to understand it just from looking at the conditional. Am I correct in understanding that this if statement is for cases where the 4 points are not collinear, but they have endpoints that are coincident?

abBB.max.X.Min(cdBB.max.X),
abBB.max.Y.Min(cdBB.max.Y),
},
if o1 == collinear && o2 == collinear && o3 == collinear && o4 == collinear {
Copy link
Owner

Choose a reason for hiding this comment

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

Is it enough just to have o1 == collinear && o2 == collinear? As that condition would imply that o3 and o4 are both collinear as well?

)
if rise.GT(zero) && run.LT(zero) || rise.LT(zero) && run.GT(zero) {
u.X, v.X = v.X, u.X
pts := make([]XY, 0, 4)
Copy link
Owner

Choose a reason for hiding this comment

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

I'm having trouble understanding what this part does. Can you add a comment?

@peterstace peterstace merged commit 1153787 into master Aug 30, 2019
@peterstace peterstace deleted the issue-16 branch August 30, 2019 04:17
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.

None yet

2 participants