/** * Computes the Z-value (elevation) of an XY point on a three-dimensional * plane defined by this triangle (whose vertices must have Z-values). This * triangle must not be degenerate (in other words, the triangle must enclose * a non-zero area), and must not be parallel to the Z-axis. * <p> * This method can be used to interpolate the Z-value of a point inside this * triangle (for example, of a TIN facet with elevations on the vertices). * * @param p * the point to compute the Z-value of * @return the computed Z-value (elevation) of the point */ public double interpolateZ(Coordinate p) { if (p == null) throw new IllegalArgumentException("Supplied point is null."); return interpolateZ(p, this.p0, this.p1, this.p2); }
/** * Computes the Z-value (elevation) of an XY point on a three-dimensional * plane defined by this triangle (whose vertices must have Z-values). This * triangle must not be degenerate (in other words, the triangle must enclose * a non-zero area), and must not be parallel to the Z-axis. * <p> * This method can be used to interpolate the Z-value of a point inside this * triangle (for example, of a TIN facet with elevations on the vertices). * * @param p * the point to compute the Z-value of * @return the computed Z-value (elevation) of the point */ public double interpolateZ(Coordinate p) { if (p == null) throw new IllegalArgumentException("Supplied point is null."); return interpolateZ(p, this.p0, this.p1, this.p2); }
@Override public void filter(CoordinateSequence seq, int i) { Coordinate coord = seq.getCoordinate(i); List<Triangle> result = q.query(new Envelope(coord)); if (!result.isEmpty()) { double z = Double.NaN; for (Triangle triangle : result) { if (TriMarkers.intersects(coord, triangle)) { z = triangle.interpolateZ(coord); break; } } seq.setOrdinate(i, 2, z ); } if (i == seq.size()) { done = true; } }
inCenter.setOrdinate(2, Triangle.interpolateZ(inCenter, triangle.p0, triangle.p1, triangle.p2)); if(intersection != null && distInters < nearestIntersection) { pointIntersection = new Coordinate(intersection.x, intersection.y, Triangle.interpolateZ(intersection, triangle.p0, triangle.p1, triangle.p2)); nearestIntersection = distInters;
inCenter.setOrdinate(2, Triangle.interpolateZ(inCenter, triangle.p0, triangle.p1, triangle.p2)); if(intersection != null && distInters < nearestIntersection) { pointIntersection = new Coordinate(intersection.x, intersection.y, Triangle.interpolateZ(intersection, triangle.p0, triangle.p1, triangle.p2)); nearestIntersection = distInters;
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); }