vertex.setZ(Double.MAX_VALUE); } else { Double aDouble = z1.get(vertex.getCoordinate()); if (aDouble != null) { vertex.setZ(aDouble); } else { vertex.setZ(Double.MAX_VALUE); for (Vertex vertex : (Collection<Vertex>) tin.getVertices(true)) { JsonFeature feature = new JsonFeature(); feature.setGeometry(geometryFactory.createPoint(vertex.getCoordinate())); HashMap<String, Object> properties = new HashMap<>(); properties.put("z", vertex.getZ()); feature.setProperties(properties); response.polygons.add(feature);
continue; processed.add(e); int cut = cut(e.orig().getZ(), e.dest().getZ(), z0); if (cut == 0) { continue; // While, next edge cC = moveEpsilonTowards(e.dest().getCoordinate(), e.orig().getCoordinate()); } else if (triangulation.isFrameVertex(e.dest())) { cC = moveEpsilonTowards(e.orig().getCoordinate(), e.dest().getCoordinate()); } else { cC = e.orig().midPoint(e.dest()).getCoordinate(); QuadEdge E1 = ccw ? e.oNext().getPrimary() : e.oPrev().getPrimary(); QuadEdge E2 = ccw ? e.dPrev().getPrimary() : e.dNext().getPrimary(); int cut1 = E1 == null ? 0 : cut(E1.orig().getZ(), E1.dest().getZ(), z0); int cut2 = E2 == null ? 0 : cut(E2.orig().getZ(), E2.dest().getZ(), z0); boolean ok1 = cut1 != 0 && !processed.contains(E1); boolean ok2 = cut2 != 0 && !processed.contains(E2);
/** * Tests whether the point pt is contained in the triangle defined by 3 * {@link Vertex}es. * * @param tri * an array containing at least 3 Vertexes * @param pt * the point to test * @return true if the point is contained in the triangle */ public static boolean contains(Vertex[] tri, Coordinate pt) { Coordinate[] ring = new Coordinate[] { tri[0].getCoordinate(), tri[1].getCoordinate(), tri[2].getCoordinate(), tri[0].getCoordinate() }; return PointLocation.isInRing(pt, ring); }
public void visit(QuadEdge[] triEdges) { Coordinate a = triEdges[0].orig().getCoordinate(); Coordinate b = triEdges[1].orig().getCoordinate(); Coordinate c = triEdges[2].orig().getCoordinate(); // TODO: choose the most accurate circumcentre based on the edges Coordinate cc = Triangle.circumcentre(a, b, c); Vertex ccVertex = new Vertex(cc); // save the circumcentre as the origin for the dual edges originating in this triangle for (int i = 0; i < 3; i++) { triEdges[i].rot().setOrig(ccVertex); } } }
public int classify(Vertex p0, Vertex p1) { Vertex p2 = this; Vertex a = p1.sub(p0); Vertex b = p2.sub(p0); double sa = a.crossProduct(b); if (sa > 0.0) return LEFT; if (sa < 0.0) return RIGHT; if ((a.getX() * b.getX() < 0.0) || (a.getY() * b.getY() < 0.0)) return BEHIND; if (a.magn() < b.magn()) return BEYOND; if (p0.equals(p2)) return ORIGIN; if (p1.equals(p2)) return DESTINATION; return BETWEEN; }
/** * returns a new vertex that is mid-way between this vertex and another end point. * * @param a the other end point. * @return the point mid-way between this and that. */ public Vertex midPoint(Vertex a) { double xm = (p.x + a.getX()) / 2.0; double ym = (p.y + a.getY()) / 2.0; double zm = (p.getZ() + a.getZ()) / 2.0; return new Vertex(xm, ym, zm); }
else if (subdiv.isOnEdge(e, v.getCoordinate())) { if (t.dest().rightOf(e) && v.isInCircle(e.orig(), t.dest(), e.dest())) { QuadEdge.swap(e); e = e.oPrev();
/** * For this vertex enclosed in a triangle defined by three vertices v0, v1 and v2, interpolate * a z value from the surrounding vertices. */ public double interpolateZValue(Vertex v0, Vertex v1, Vertex v2) { double x0 = v0.getX(); double y0 = v0.getY(); double a = v1.getX() - x0; double b = v2.getX() - x0; double c = v1.getY() - y0; double d = v2.getY() - y0; double det = a * d - b * c; double dx = this.getX() - x0; double dy = this.getY() - y0; double t = (d * dx - b * dy) / det; double u = (-c * dx + a * dy) / det; double z = v0.getZ() + t * (v1.getZ() - v0.getZ()) + u * (v2.getZ() - v0.getZ()); return z; }
/** * Computes the centre of the circumcircle of this vertex and two others. * * @param b * @param c * @return the Coordinate which is the circumcircle of the 3 points. */ public Vertex circleCenter(Vertex b, Vertex c) { Vertex a = new Vertex(this.getX(), this.getY()); // compute the perpendicular bisector of cord ab HCoordinate cab = bisector(a, b); // compute the perpendicular bisector of cord bc HCoordinate cbc = bisector(b, c); // compute the intersection of the bisectors (circle radii) HCoordinate hcc = new HCoordinate(cab, cbc); Vertex cc = null; try { cc = new Vertex(hcc.getX(), hcc.getY()); } catch (NotRepresentableException nre) { System.err.println("a: " + a + " b: " + b + " c: " + c); System.err.println(nre); } return cc; }
for (Vertex vertex : (Collection<Vertex>) tin.getVertices(true)) { if (tin.isFrameVertex(vertex)) { vertex.setZ(Double.MAX_VALUE);
/** * Computes the value of the ratio of the circumradius to shortest edge. If smaller than some * given tolerance B, the associated triangle is considered skinny. For an equal lateral * triangle this value is 0.57735. The ratio is related to the minimum triangle angle theta by: * circumRadius/shortestEdge = 1/(2sin(theta)). * * @param b second vertex of the triangle * @param c third vertex of the triangle * @return ratio of circumradius to shortest edge. */ public double circumRadiusRatio(Vertex b, Vertex c) { Vertex x = this.circleCenter(b, c); double radius = distance(x, b); double edgeLength = distance(this, b); double el = distance(b, c); if (el < edgeLength) { edgeLength = el; } el = distance(c, this); if (el < edgeLength) { edgeLength = el; } return radius / edgeLength; }
/** * Computes the scalar product c(v) * * @param v a vertex * @return returns the scaled vector */ Vertex times(double c) { return (new Vertex(c * p.x, c * p.y)); }
public static Geometry toPolygon(Vertex[] v) { Coordinate[] ringPts = new Coordinate[] { v[0].getCoordinate(), v[1].getCoordinate(), v[2].getCoordinate(), v[0].getCoordinate() }; GeometryFactory fact = new GeometryFactory(); LinearRing ring = fact.createLinearRing(ringPts); Polygon tri = fact.createPolygon(ring); return tri; }
continue; processed.add(e); int cut = cut(e.orig().getZ(), e.dest().getZ(), z0); if (cut == 0) { continue; // While, next edge cC = moveEpsilonTowards(e.dest().getCoordinate(), e.orig().getCoordinate()); } else if (triangulation.isFrameVertex(e.dest())) { cC = moveEpsilonTowards(e.orig().getCoordinate(), e.dest().getCoordinate()); } else { cC = e.orig().midPoint(e.dest()).getCoordinate(); QuadEdge E1 = ccw ? e.oNext().getPrimary() : e.oPrev().getPrimary(); QuadEdge E2 = ccw ? e.dPrev().getPrimary() : e.dNext().getPrimary(); int cut1 = E1 == null ? 0 : cut(E1.orig().getZ(), E1.dest().getZ(), z0); int cut2 = E2 == null ? 0 : cut(E2.orig().getZ(), E2.dest().getZ(), z0); boolean ok1 = cut1 != 0 && !processed.contains(E1); boolean ok2 = cut2 != 0 && !processed.contains(E2);
private void createFrame(Envelope env) { double deltaX = env.getWidth(); double deltaY = env.getHeight(); double offset = 0.0; if (deltaX > deltaY) { offset = deltaX * 10.0; } else { offset = deltaY * 10.0; } frameVertex[0] = new Vertex((env.getMaxX() + env.getMinX()) / 2.0, env .getMaxY() + offset); frameVertex[1] = new Vertex(env.getMinX() - offset, env.getMinY() - offset); frameVertex[2] = new Vertex(env.getMaxX() + offset, env.getMinY() - offset); frameEnv = new Envelope(frameVertex[0].getCoordinate(), frameVertex[1] .getCoordinate()); frameEnv.expandToInclude(frameVertex[2].getCoordinate()); }
for (Vertex vertex : (Collection<Vertex>) tin.getVertices(true)) { if (tin.isFrameVertex(vertex)) { vertex.setZ(Double.MAX_VALUE);
Vertex cross() { return (new Vertex(p.y, -p.x)); }
private Coordinate[] getPointArray() { Coordinate[] pts = new Coordinate[initialVertices.size() + segVertices.size()]; int index = 0; for (Iterator i = initialVertices.iterator(); i.hasNext();) { Vertex v = (Vertex) i.next(); pts[index++] = v.getCoordinate(); } for (Iterator i2 = segVertices.iterator(); i2.hasNext();) { Vertex v = (Vertex) i2.next(); pts[index++] = v.getCoordinate(); } return pts; }