-
-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Added Jarvis Algorithm to compute convex hull #1027
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
Conversation
|
This implements #1026 . Can you review @Panquesito7. I have tried my best to align it with all the guidelines and squashed all commit s to one :) |
|
Thanks for the review, I have updated the PR with your suggested changes. |
Panquesito7
left a comment
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.
For enhanced formatting and code, please enable GitHub Actions in your fork of this repository.
Anyways, though, how does the program work? I have compiled it and it gives no output.
We start from the leftmost point (or point with minimum x coordinate value) and we keep wrapping points in counterclockwise direction with the use of orientation() function. Next point is selected as the point that beats all other points at counterclockwise orientation, i.e., next point is q if for any other point r, we have “orientation(p, q, r) = counterclockwise” ,ie, 1.... I have just added test which asserts the expected value without printing anything. Should i display the hull as well in the function ??? You can add breakpoint to see the actual value returned |
No, I think I got confused. You can show what will it output in the first comment block. |
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.
Looks really refined and good, excellent work! 👍
Now, let's output if the tests have passed, or not.
Fixed code formatting Fixed code formatting Fixed code formatting Added Jarvis algorithm to compute convex hull Capitalized class name Added requested changes Added requested changes Added jarvis algorithm Added jarvis algorithm to compute convex hull
Thanks, I have added all the changes you suggested. Will be more careful with the guidelines in the next PR. |
|
@rishabh-997 please make sure to add your implementation link in the repo directory, here after it gets merged! Nice work though!! |
Co-authored-by: David Leal <halfpacho@gmail.com>
Co-authored-by: David Leal <halfpacho@gmail.com>
Panquesito7
left a comment
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.
Please consider enabling GitHub Actions in your fork of this repository for enhanced code and formatting.
Co-authored-by: David Leal <halfpacho@gmail.com>
Yes sure, i will look how to add this and make sure to use it in my next PR. Thanks :) |
Panquesito7
left a comment
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.
Excellent work; LGTM. 👍
Thank you for your contribution.
@kvedala please review as well. Thank you. 🙂
kvedala
left a comment
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.
Looks great. Some doc corrections and a suggestion.
| */ | ||
| class Convexhull { | ||
| public: | ||
| std::vector<Point> points; |
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.
should the variables points and size be private?
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.
isnt size redundant, given that the value is already present in the std::vector?
|
👍 |
|
@Panquesito7 do squash merge. |
|
@kvedala Sorry for the confusions, I will in the future. Thanks! 🙂 |
Description of Change
Closes #1026.
I implemented the Jarvis algorithm which, for a set of points in the plane, creates a convex hull of the points in the smallest convex polygon that contains all the points of it.
Checklist
Notes: