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

Add Convex Hull JavaScript #3441

Merged
merged 6 commits into from
Oct 31, 2023
Merged

Conversation

GriffinAnnshual
Copy link
Contributor

@GriffinAnnshual GriffinAnnshual commented Oct 9, 2023

Congrats on taking the first step to contributing to the Sample Programs repository maintained by The Renegade Coder!
For simplicity, please make sure that your pull request includes one and only one contribution.

Please fill one of the sections below as applicable.
Please also add any other relevant information to the Notes section at the bottom.
You may delete or just ignore any other sections.
For more information please refer to our contributing documentation

I Am Adding a New Code Snippet in an Existing Language

@rzuckerm rzuckerm added enhancement Any code that improves the repo hacktoberfest Hacktoberfest related convex hull See: https://sampleprograms.io/projects/convex-hull/ labels Oct 9, 2023
Copy link
Collaborator

@rzuckerm rzuckerm left a comment

Choose a reason for hiding this comment

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

Looks like you have several test failures to address. One of these is the error message, which should be this:

Usage: please provide at least 3 x and y coordinates as separate lists (e.g. "100, 440, 210")

@rzuckerm
Copy link
Collaborator

rzuckerm commented Oct 9, 2023

@GriffinAnnshual I'll give you hint as to a problem with your implementation. You missing a key first step. See this for details.

@GriffinAnnshual
Copy link
Contributor Author

GriffinAnnshual commented Oct 10, 2023

@rzuckerm Bro where is the mistake is it in the implementation or on the test cases? Could you please help?

@rzuckerm
Copy link
Collaborator

@rzuckerm Bro where is the mistake is it in the implementation or on the test cases? Could you please help?

The mistake in the implementation is that the first point is used to calculate the angles. According to this, the point with the lowest y-coordinate is supposed to be used:

find the lowest y-coordinate and leftmost point, called P0
sort points by polar angle with P0, if several points have the same polar angle then only keep the farthest

The test case that is failing called called "Sample Input Pentagon" in this.

@GriffinAnnshual
Copy link
Contributor Author

GriffinAnnshual commented Oct 10, 2023

Okay got it.. I will work on it.

Copy link
Collaborator

@rzuckerm rzuckerm left a comment

Choose a reason for hiding this comment

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

Since this is the last day of Hacktoberfest, I went ahead and fixed this sample since it was pretty close to working.

@rzuckerm rzuckerm merged commit 13d7099 into TheRenegadeCoder:main Oct 31, 2023
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
convex hull See: https://sampleprograms.io/projects/convex-hull/ enhancement Any code that improves the repo hacktoberfest Hacktoberfest related
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Convex Hull in Javascript
3 participants