-
Notifications
You must be signed in to change notification settings - Fork 494
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
added in CH_andrew #71
base: master
Are you sure you want to change the base?
Conversation
AGIS DANIELS EDITS I made this compressed version of the code from c++ and a python version on wikibooks toVec was moved to sub as toVec(a,b)== b-a tested this on 2 kattis problems my own version works on tested on 4 problems but it requires area and perimeter to work ccw and cross are almost the same in python as in c++ i added in a few things into the point class for it to solve the two convex hull problems on kattis that i tested on
if you would like me to make a second branch and resubmit the pull request i will do so upon asking |
Ok just continue adding commits to this PR like this. Once a while (not every time you have updates), I will review and decide to merge or ask you to modify further. @seffendy is good with Python so he can also help comments on this PR. |
Agis Daniels for consistency reasons i removed sub and re added vec ccw already used it in a difference file so i just used it from the points line .py as well < had a more elegant version from that file too so i used it here too retested and still holds ac on kattis
Agis Daniels nice one liner for area i called cross product function to avoid the need to retype the code again should help avoid typos when implementing it from paper the less than for point seems to work nicely with floats :) also added a oneliner version of the perimeter function above the code as well
Agis daniels
Agis Daniels they already existed in other files polyline.py is where i took these ones from also why is origin needed in the alt version of polygon area ??
Agis Daniels already existed in pointlines file so i just used the one from there
Agis Daniels the code i use in my own implementation is similar so i can just swap out my call with ccw as its similar to the c++ code :)
Agis Daniels im a bit iffy on insidePolygon as i tried to implment it before both like this and super mega compressed version and it had some errors for some reason the second loop had errors i mean will need to ask suhendry about it
Agis daniels good to go
Agis Daniels edit be sure to remove these two lines and set them to 0 in the __init__ function to my understanding those are class variables shared by all instances of the class as stated in this link https://docs.python.org/3/tutorial/classes.html#class-and-instance-variables
removed two lines
good thing is this was the only part for python in this repo where i seen the bug |
I coded up the rest of the functions while trying to stay true to the source code from c++ i ran into some bugs for CH_Graham scan which i need help understanding
Agis daniels
got the file all implemented with respect to the c++ code provided however i need some help understanding the CH_Graham implementation as i had to switch a bit of code to make is work @seffendy |
My name is Agis Daniels and here are my edits
AGIS DANIELS EDITS
I made this compressed version of the code from c++ and a python version on wikibooks
toVec was moved to sub as toVec(a,b)== b-a
tested this on 2 kattis problems
my own version works on tested on 4 problems but it requires area and perimeter to work
ccw and cross are almost the same in python as in c++
i added in a few things into the point class for it to solve the two convex hull problems on kattis that i tested on