/** * 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. * * @return 1 if q is counter-clockwise from p1-p2 * @return -1 if q is clockwise from p1-p2 * @return 0 if q is collinear with p1-p2 */ public static int computeOrientation(Coordinate p1, Coordinate p2, Coordinate q) { return orientationIndex(p1, p2, q); }
/** * Determines the orientation index of a {@link Coordinate} relative to this segment. * The orientation index is as defined in {@link CGAlgorithms#computeOrientation}. * * @param p the coordinate to compare * * @return 1 (LEFT) if <code>p</code> is to the left of this segment * @return -1 (RIGHT) if <code>p</code> is to the right of this segment * @return 0 (COLLINEAR) if <code>p</code> is collinear with this segment * * @see CGAlgorithms#computeOrientation(Coordinate, Coordinate, Coordinate) */ public int orientationIndex(Coordinate p) { return CGAlgorithms.orientationIndex(p0, p1, p); }
int orient0 = CGAlgorithms.orientationIndex(p0, p1, seg.p0); int orient1 = CGAlgorithms.orientationIndex(p0, p1, seg.p1);
public void computeIntersection(Coordinate p, Coordinate p1, Coordinate p2) { isProper = false; // do between check first, since it is faster than the orientation test if (Envelope.intersects(p1, p2, p)) { if ((CGAlgorithms.orientationIndex(p1, p2, p) == 0) && (CGAlgorithms.orientationIndex(p2, p1, p) == 0)) { isProper = true; if (p.equals(p1) || p.equals(p2)) { isProper = false; } result = POINT_INTERSECTION; return; } } result = NO_INTERSECTION; }
int Pq1 = CGAlgorithms.orientationIndex(p1, p2, q1); int Pq2 = CGAlgorithms.orientationIndex(p1, p2, q2); int Qp1 = CGAlgorithms.orientationIndex(q1, q2, p1); int Qp2 = CGAlgorithms.orientationIndex(q1, q2, p2);
/** * Determines the orientation index of a {@link Coordinate} relative to this segment. * The orientation index is as defined in {@link CGAlgorithms#computeOrientation}. * * @param p the coordinate to compare * * @return 1 (LEFT) if <code>p</code> is to the left of this segment * @return -1 (RIGHT) if <code>p</code> is to the right of this segment * @return 0 (COLLINEAR) if <code>p</code> is collinear with this segment * * @see CGAlgorithms#computeOrientation(Coordinate, Coordinate, Coordinate) */ public int orientationIndex(Coordinate p) { return CGAlgorithms.orientationIndex(p0, p1, p); }
/** * 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); }
int orient0 = CGAlgorithms.orientationIndex(p0, p1, seg.p0); int orient1 = CGAlgorithms.orientationIndex(p0, p1, seg.p1);
public void computeIntersection(Coordinate p, Coordinate p1, Coordinate p2) { isProper = false; // do between check first, since it is faster than the orientation test if (Envelope.intersects(p1, p2, p)) { if ((CGAlgorithms.orientationIndex(p1, p2, p) == 0) && (CGAlgorithms.orientationIndex(p2, p1, p) == 0)) { isProper = true; if (p.equals(p1) || p.equals(p2)) { isProper = false; } result = POINT_INTERSECTION; return; } } result = NO_INTERSECTION; }
int Pq1 = CGAlgorithms.orientationIndex(p1, p2, q1); int Pq2 = CGAlgorithms.orientationIndex(p1, p2, q2); int Qp1 = CGAlgorithms.orientationIndex(q1, q2, p1); int Qp2 = CGAlgorithms.orientationIndex(q1, q2, p2);
final Coordinate intersect = line_.getIntersectedPoint(); final double d = CtuluLibGeometrie.getD2(_l1.x, _l1.y, intersect.x, intersect.y); if (CGAlgorithms.orientationIndex(_p1, _p2, intersect) == CGAlgorithms.COUNTERCLOCKWISE) { if (d2 < 0 || d < d2) { d2 = d; final int trigo = CGAlgorithms.orientationIndex(_p1, _p2, resCor_[1]); if (trigo != CGAlgorithms.COUNTERCLOCKWISE) { final Coordinate tmp = resCor_[0];
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); }
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); }