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

connecting segment doesn't always intersect what it connects with #3

Open
bootchk opened this issue Jan 4, 2013 · 1 comment
Open

Comments

@bootchk
Copy link

bootchk commented Jan 4, 2013

This is python code snippet that shows the problem:

intersection = segment.connect(pointLCS).intersect(segment)

Sometimes it returns None, which seems suspect.

In plain language, given any point and any first segment, a second segment that connects the point to the first segment should intersect the first segment.

I haven't really analyzed it yet. It could be that it fails when the point is colinear with the first segment. Or it could be a faulty set interpretation of segments: the end points of segments are not in the segment, i.e. the set of points in a segment is an open set. Or when the connecting segment has magnitude 0 i.e. a point, that causes problems? Or it may be when the first segment is vertical? Or maybe my understanding of geometry is incorrect: a connecting segment does not intersect?

I have been reading "Computational Geometry In C" by O'Rourke. He discusses the extreme difficulty of getting intersect() correct when using point slope algorithms, which pyeuclid does. There are many edge cases (such as vertical lines.) So I am considering the alternative which he proposes, using "signed area between three points."

This shows the test cases for pyeuclid are insufficient. But I can't find a complete set of test cases (axioms, postulates?) for geometry on the net. Seems like that would be useful.

I already have branched, just not made it public. The OO design of pyeuclid is strange, and one giant source code file is hard to read. The emphasis seems to be on performance, at the cost of correctness. I just need the geometrical objects, and use transformations from elsewhere (Qt.)

@bootchk
Copy link
Author

bootchk commented Feb 13, 2013

One way to fix this is to implement nearestPoint(point, other). It returns the appropriate end point of the connecting segment (the end point that intersects other.) Similarly as distance() is based on connect().

It raises the issue: what is the nearest point on a circle to the center point of the circle? Another edge test case that pyeuclid doesn't address?

Also, more guessing: the problem: "segment.connect(pointLCS).intersect(segment) returns None" might only show up for vertical lines? Or it could be a floating point issue?

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

1 participant