CGAlgorithms.computeOrientation(firstCoord, midCoord, lastCoord);
/** *@return whether the three coordinates are collinear and c2 lies between * c1 and c3 inclusive */ private boolean isBetween(Coordinate c1, Coordinate c2, Coordinate c3) { if (CGAlgorithms.computeOrientation(c1, c2, c3) != 0) { return false; } if (c1.x != c3.x) { if (c1.x <= c2.x && c2.x <= c3.x) { return true; } if (c3.x <= c2.x && c2.x <= c1.x) { return true; } } if (c1.y != c3.y) { if (c1.y <= c2.y && c2.y <= c3.y) { return true; } if (c3.y <= c2.y && c2.y <= c1.y) { return true; } } return false; }
double dyq = q.y - o.y; int orient = CGAlgorithms.computeOrientation(o, p, q);
/** * Uses the Graham Scan algorithm to compute the convex hull vertices. * * @param c a list of points, with at least 3 entries * @return a Stack containing the ordered points of the convex hull ring */ private Stack grahamScan(Coordinate[] c) { Coordinate p; Stack ps = new Stack(); p = (Coordinate) ps.push(c[0]); p = (Coordinate) ps.push(c[1]); p = (Coordinate) ps.push(c[2]); for (int i = 3; i < c.length; i++) { p = (Coordinate) ps.pop(); // check for empty stack to guard against robustness problems while ( ! ps.empty() && CGAlgorithms.computeOrientation((Coordinate) ps.peek(), p, c[i]) > 0) { p = (Coordinate) ps.pop(); } p = (Coordinate) ps.push(p); p = (Coordinate) ps.push(c[i]); } p = (Coordinate) ps.push(c[0]); return ps; }
/** * Reverse the LineString to be oriented counter-clockwise. * @param lineString * @return */ private static LineString getCounterClockWise(final LineString lineString) { final Coordinate c0 = lineString.getCoordinateN(0); final Coordinate c1 = lineString.getCoordinateN(1); final Coordinate c2 = lineString.getCoordinateN(2); lineString.apply(new UpdateZCoordinateSequenceFilter(0, 3)); if (CGAlgorithms.computeOrientation(c0, c1, c2) == CGAlgorithms.COUNTERCLOCKWISE) { return lineString; } else { return (LineString) lineString.reverse(); } }
/** * Reverse the LineString to be oriented clockwise. * All NaN z values are replaced by a zero value. * @param lineString * @return */ private static LineString getClockWise(final LineString lineString) { final Coordinate c0 = lineString.getCoordinateN(0); final Coordinate c1 = lineString.getCoordinateN(1); final Coordinate c2 = lineString.getCoordinateN(2); lineString.apply(new UpdateZCoordinateSequenceFilter(0, 3)); if (CGAlgorithms.computeOrientation(c0, c1, c2) == CGAlgorithms.CLOCKWISE) { return lineString; } else { return (LineString) lineString.reverse(); } }
return false; int disc = computeOrientation(prev, hiPt, next);