private int getOrientationIndex(LineString ls) { return CGAlgorithms.orientationIndex( ls.getCoordinateN(0), ls.getCoordinateN(1), ls.getCoordinateN(2)); }
/** * Computes the orientation of a point q to the directed line segment p1-p2. * The orientation of a point relative to a directed line segment indicates * which way you turn to get to q after travelling from p1 to p2. * * @param p1 the first vertex of the line segment * @param p2 the second vertex of the line segment * @param q the point to compute the relative orientation of * @return 1 if q is counter-clockwise from p1-p2, * or -1 if q is clockwise from p1-p2, * or 0 if q is collinear with p1-p2 */ public static int computeOrientation(Coordinate p1, Coordinate p2, Coordinate q) { return orientationIndex(p1, p2, q); }
private double fetchZ(Coordinate pt, int idGeom) { Triangle curTri = getTriangle(idGeom); while(!triangleContainsPoint(curTri, pt)) { // Fetch neighbor where pt lies at the other side of triangle segment int bestNeigh = -1; for(int idSeg = 0; idSeg < 3; idSeg++) { LineSegment seg = getTriangleSegment(idGeom, idSeg); int ptPos = CGAlgorithms.orientationIndex(seg.p0, seg.p1, pt); if(CGAlgorithms.isCCW(inputTriangles.getGeometryN(idGeom).getCoordinates())) { ptPos = -ptPos; } if(ptPos == 1) { bestNeigh = idSeg; break; } else if(ptPos == 0 && bestNeigh == -1) { bestNeigh = idSeg; } } if(bestNeigh != -1) { idGeom = triangleNeighbors[idGeom].get(bestNeigh); if(idGeom >= 0) { curTri = getTriangle(idGeom); } else { return Double.NaN; } } } return curTri.interpolateZ(pt); }