Sorry if I'm stepping in on something that you may already know to sort it out, but I was looking at it, and I thought whether it would be enough to iterate through the points as I said. I tested the code locally. I'll paste it below. It corresponds to NumericalMethods.java . Maybe you can take this comment into account, or ask me to submit a pull request, or deal with this as you please. Either way, I'm cool with it. public static boolean isCounterClockwise(PositionSequence<?> positions) { if (positions.size() < 3) return true; Position p0 = positions.getPositionN(0); Position p1 = positions.getPositionN(1); double det = 0; int positionsSize = positions.size(); int i = 2; while(i < positionsSize && det == 0) { Position p2 = positions.getPositionN(i); det = deltaDeterminant(p0, p1, p2); i++; } if (det == 0) { throw new IllegalArgumentException("Positions are collinear in 2D"); } return det > 0; } |