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

Graham's Scan implementation #123

Merged
merged 11 commits into from
Sep 11, 2017
Merged

Conversation

matheusdallrosa
Copy link
Contributor

My changes provide an implementation of the Graham's scan algorithm, basic 2D vector operations and tests for both.

@coveralls
Copy link

coveralls commented Sep 8, 2017

Coverage Status

Coverage decreased (-0.04%) to 96.477% when pulling f991768 on matheusdallrosa:master into 6d2de49 on felipernb:master.

Copy link
Contributor

@shuding shuding left a comment

Choose a reason for hiding this comment

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

Looks great, thanks! 🍻

return P;
}
preprocessing(P);
console.log(P);
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you please remove this debugging info?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, i forgot it.

let j = convexHull.length;
while (j >= 2 &&
vectorOp.
parallelogramArea(convexHull[j-2], convexHull[j-1], P[i]) <= 0) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we use the isClockwise helper here? (or !isCounterClockwise)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually we can't, because both isClockwise and isCounterClockwise return false when the points are collinear, but we want to remove them from the convexHull when they are collinear.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually we can use !isCounterClockwise, it will do the same job. I'll change it soon.

@coveralls
Copy link

coveralls commented Sep 10, 2017

Coverage Status

Coverage decreased (-0.04%) to 96.475% when pulling 8a78249 on matheusdallrosa:master into 6d2de49 on felipernb:master.

@coveralls
Copy link

coveralls commented Sep 11, 2017

Coverage Status

Coverage increased (+0.02%) to 96.532% when pulling 400b9ca on matheusdallrosa:master into 6d2de49 on felipernb:master.

Copy link
Owner

@felipernb felipernb left a comment

Choose a reason for hiding this comment

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

Looks good, but it would be nice to make two small changes:

  1. for consistency, always use arrow functions
  2. variable names always starting in lower case (i.e. the P passed to the grahamScan function).

Other than that, everything is great, thanks for the contribution!

@coveralls
Copy link

coveralls commented Sep 11, 2017

Coverage Status

Coverage increased (+0.01%) to 96.526% when pulling dc7cf4d on matheusdallrosa:master into 6d2de49 on felipernb:master.

@felipernb felipernb merged commit 02aea73 into felipernb:master Sep 11, 2017
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

4 participants