Hello. I agree that the docs are not really clear on the "natural orientation" part there. Basically, the possible results are as follows:
* positive - The argument lies on the right side of the calling line, with the "right side" defined as the side on the right when looking along the calling line in its defined direction. (This is what I believe is meant by "natural orientation".) * negative - The argument lies on the left side of the calling line. * zero - The lines have points in common, meaning they intersect or are coincident. On a side note, if you're writing geometric code, I would suggest trying out the new(-ish) commons-geometry library [1]. It is a rewrite and extension of the commons-math geometry code and, IMHO, the API is more user-friendly. (Disclaimer: I wrote the majority of it so I am completely biased 🙂 Regards, Matt J [1] https://commons.apache.org/proper/commons-geometry/ [https://avatars.githubusercontent.com/u/47359?s=400&v=4]<https://github.com/apache/commons-geometry/blob/master/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/Line.java#L370> apache/commons-geometry<https://github.com/apache/commons-geometry/blob/master/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/Line.java#L370> Apache Commons Geometry. Contribute to apache/commons-geometry development by creating an account on GitHub. github.com ________________________________ From: Patrik Karlström <[email protected]> Sent: Thursday, March 18, 2021 3:42 AM To: [email protected] <[email protected]> Subject: Re: [math] 2D Line getOffset and natural orientation Oh, scratch that! I had three parallel lines and picked the wrong pair (and the correct values came from another calculation). Still interested in "natural orientation" though. Den tors 18 mars 2021 kl 07:19 skrev Patrik Karlström <[email protected]>: > > Sometimes (50/50?) I'm getting an unexpected signum from > org.apache.commons.math3.geometry.euclidean.twod.Line.getOffset(Line > line). > The absolute value itself is correct. > > From the javadoc: > "The offset is 0 if both lines are the same, it is positive if the > line is on the right side of the instance and negative if it is on the > left side, according to its natural orientation." > > I suspect my problem relates to "according to its natural orientation." > What is a natural orientation and what can I do to adapt to it, when > to reverse my lines? If that's the case. > > https://commons.apache.org/proper/commons-math/javadocs/api-3.6.1/org/apache/commons/math3/geometry/euclidean/twod/Line.html#getOffset(org.apache.commons.math3.geometry.euclidean.twod.Line) --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
