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

Python port & binding #108

Open
lycantropos opened this issue Sep 15, 2020 · 2 comments
Open

Python port & binding #108

lycantropos opened this issue Sep 15, 2020 · 2 comments

Comments

@lycantropos
Copy link

lycantropos commented Sep 15, 2020

I've written pure Python port with separate C++ binding (available on PyPI), according to pseudo-randomized tests it is equivalent to the original C++ code.

Also locally I've tried to use Fractions instead of integers for coordinates, but without success, it seems that this kind of generalization requires deep understanding of the underlying algorithm which I unfortunately don't have.

@flippmoke
Copy link
Member

@lycantropos that is awesome!

It is not possible with this algorithm to operate with floating point values currently. There is quite a bit of logic in the algorithm itself that currently relies on the math to work in integers, one of the biggest issues is detecting order of intersections and handling shared points if the algorithm is shifted to floating point values. I do not see a way to do this effectively. If the algorithm wants to handle floating point values, the best thing might be to simply scale up floating points value to an integer range then downscale the integer values after to floating point. Unfortunately, downscaling can introduce some new invalid features into the polygon in some cases, so this is hard to generalize.

@bretttully
Copy link

@lycantropos I hope you don't mind, but I have just opened a PR to get your package onto conda-forge: conda-forge/staged-recipes#13283

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

No branches or pull requests

3 participants