-
Notifications
You must be signed in to change notification settings - Fork 19
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
Conversation
geom/alg_intersection.go
Outdated
o3 := orientation(c, d, a) | ||
o4 := orientation(c, d, b) | ||
|
||
if o1 != o2 && |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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?
geom/alg_intersection.go
Outdated
abBB.max.X.Min(cdBB.max.X), | ||
abBB.max.Y.Min(cdBB.max.Y), | ||
}, | ||
if o1 == collinear && o2 == collinear && o3 == collinear && o4 == collinear { |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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?
No description provided.