javaGeom icon indicating copy to clipboard operation
javaGeom copied to clipboard

Line2D intersection bug

Open ben-horner opened this issue 6 years ago • 5 comments

For some reason the implementation of Line2D.intersection(Line2D) is using a LineSegment2D here: https://github.com/dlegland/javaGeom/blob/master/src/main/java/math/geom2d/line/Line2D.java#L345

Then when the AbstractLine2D.instersect method takes over, it correctly finds the intersection, but then it checks LineSegment2D.contains(), and the intersection, though correct, may not be included in that segment... I don't know if this class was deprecated or what.

StraightLine2D seems to work correctly.

ben-horner avatar Apr 07 '19 08:04 ben-horner

Hi, In fact, this class was designed to mimick the behaviour of java.awt.Line2D , and so, it is intended to have the same behaviour as a line segment (The difference with the class LineSegment2D is the way the information are internally stored). I have the impression you were expected it to work like an infinite straight line, but it is finite by nature.

Does it clarify?

dlegland avatar May 21 '19 18:05 dlegland

It does clarify the issue. FWIW, I read what comments are present, and still this did not occur to me. I doubt updating comments are high priority, but noting somewhere in the class that it's meant to mimic Line2D would have given me somewhere else to look to understand it's behavior.

Thanks for the library, it's been very useful to me.

ben-horner avatar May 26 '19 04:05 ben-horner

I agree, doc could be more explicit... Unfortunately it's not on the highest priorities, but as the library does not evolve much, I will try to give a boost to the doc.

dlegland avatar May 26 '19 15:05 dlegland

Is the 3d portion of the library trustworthy at all? (Specifically thinking of the version available through maven.)

ben-horner avatar Jul 08 '19 05:07 ben-horner

Hi, The 3d portion of the lib is more a stub than a real library... There are some unit tests, so tested parts can should be trustworthy. But I haven't used it in any project yet.

dlegland avatar Jul 08 '19 07:07 dlegland