-
Notifications
You must be signed in to change notification settings - Fork 940
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 methods to determine orientation of PolyLine #1411
Conversation
eac346f
to
1061a12
Compare
1061a12
to
0b48b34
Compare
0b48b34
to
dc77ff1
Compare
I think this is pretty solid at this point. I've been using it along with some CGAL code that would barf if the orientation wasn't always CCW so It helped me track down a couple of small bugs in this. Those issues helped inspire some of the test cases. |
Thanks for your work on this and apologies for the delay. The implementation looks good to me, minus a few formatting things I can easily fix. It's a 100% subjective but I'd like to propose an interface tweak. For the most part we avoid function-specific enums in Cinder. To that end, I'd propose we ditch the
Again, I realize this is mostly just a different flavor of imperfect, but this would be a bit more consistent with Cinder at large. |
I'd just followed the pattern that CGAL was using so I'm happy to make those changes. Feel free to point out any other spots with formatting issues. |
Hey - the formatting stuff I'm noticing are mostly extra spaces, like It's not all-encompassing but most of the important stuff is in the Contributing guide. And I will take a look at the other two as well while we're in here. |
@andrewfb Ah, thanks... I'll give that a closer read. So are you proposing dropping the |
dc77ff1
to
1516078
Compare
I'd propose dropping it.
is roughly how I'd see this used in a case where we need to handle colinear. For the case where we're not worried about it:
Open to other opinions here, but I think the main advantage to |
@andrewfb I took a pass at this and I'm pretty happy with how it turned out. I made the changes as a separate commit so you could compare the two approaches. I can squash that down when you're happy or you can do that when you merge. |
226e356
to
9c9c2b7
Compare
9c9c2b7
to
c1a91f3
Compare
I went ahead and rebased this to pick up the other polyline changes and squashed it down. |
Thanks very much for this, particularly for including the unit test cases. I made a minor tweak - a case change to make |
Ah nice data point for the naming. Glad to finally see this merged. |
I'd been using CGAL's Polygon_2 to determine the orientation but realized the math isn't that complicated and would be a nice addition to the PolyLine class.
The algorithm is based of this answer the FAQ for comp.graphics.algorithms:
And some other details I found on the Wikipedia Curve orientation page.
The code
is kind of klunky butworks well. It includes some basic unit tests.