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();
vertex.setZ(Double.MAX_VALUE); } else { Double aDouble = z1.get(vertex.getCoordinate()); if (aDouble != null) { vertex.setZ(aDouble); 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());
/** * 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 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; }
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; }
public boolean equals(Vertex _x, double tolerance) { if (p.distance(_x.getCoordinate()) < tolerance) { return true; } else { return false; } }
/** * Creates a {@link LineSegment} representing the * geometry of this edge. * * @return a LineSegment */ public LineSegment toLineSegment() { return new LineSegment(vertex.getCoordinate(), dest().getCoordinate()); }
/** * Converts this edge to a WKT two-point <tt>LINESTRING</tt> indicating * the geometry of this edge. * * @return a String representing this edge's geometry */ public String toString() { Coordinate p0 = vertex.getCoordinate(); Coordinate p1 = dest().getCoordinate(); return WKTWriter.toLineString(p0, p1); } }
public void getEdgeSegment(int i, LineSegment seg) { seg.p0 = edge[i].orig().getCoordinate(); int nexti = (i + 1) % 3; seg.p1 = edge[nexti].orig().getCoordinate(); }
public Coordinate getCoordinate(int i) { return edge[i].orig().getCoordinate(); }
private static Envelope computeVertexEnvelope(Collection vertices) { Envelope env = new Envelope(); for (Iterator i = vertices.iterator(); i.hasNext();) { Vertex v = (Vertex) i.next(); env.expandToInclude(v.getCoordinate()); } return env; }
@Override public void visit(QuadEdge[] triEdges) { Coordinate a = triEdges[0].orig().getCoordinate(); Coordinate b = triEdges[1].orig().getCoordinate(); Coordinate c = triEdges[2].orig().getCoordinate(); circumCenters.add(Triangle.circumcentre(a, b, c)); } }
/** * Gets the length of the geometry of this quadedge. * * @return the length of the quadedge */ public double getLength() { return orig().getCoordinate().distance(dest().getCoordinate()); }
/** * Tests whether the point pt is contained in the triangle defined by 3 * {@link QuadEdge}es. * * @param tri * an array containing at least 3 QuadEdges * @param pt * the point to test * @return true if the point is contained in the triangle */ public static boolean contains(QuadEdge[] tri, Coordinate pt) { Coordinate[] ring = new Coordinate[] { tri[0].orig().getCoordinate(), tri[1].orig().getCoordinate(), tri[2].orig().getCoordinate(), tri[0].orig().getCoordinate() }; return PointLocation.isInRing(pt, ring); }
/** * Tests if this quadedge and another have the same line segment geometry * with the same orientation. * * @param qe a quadedge * @return true if the quadedges are based on the same line segment */ public boolean equalsOriented(QuadEdge qe) { if (orig().getCoordinate().equals2D(qe.orig().getCoordinate()) && dest().getCoordinate().equals2D(qe.dest().getCoordinate())) return true; return false; }
public static Geometry toPolygon(QuadEdge[] e) { Coordinate[] ringPts = new Coordinate[] { e[0].orig().getCoordinate(), e[1].orig().getCoordinate(), e[2].orig().getCoordinate(), e[0].orig().getCoordinate() }; GeometryFactory fact = new GeometryFactory(); LinearRing ring = fact.createLinearRing(ringPts); Polygon tri = fact.createPolygon(ring); return tri; }
public Coordinate[] getCoordinates() { Coordinate[] pts = new Coordinate[4]; for (int i = 0; i < 3; i++) { pts[i] = edge[i].orig().getCoordinate(); } pts[3] = new Coordinate(pts[0]); return pts; }
/** * Tests whether a {@link Coordinate} lies on a {@link QuadEdge}, up to a * tolerance determined by the subdivision tolerance. * * @param e * a QuadEdge * @param p * a point * @return true if the vertex lies on the edge */ public boolean isOnEdge(QuadEdge e, Coordinate p) { seg.setCoordinates(e.orig().getCoordinate(), e.dest().getCoordinate()); double dist = seg.distance(p); // heuristic (hack?) return dist < edgeCoincidenceTolerance; }
/** * Gets the primary edge of this quadedge and its <tt>sym</tt>. * The primary edge is the one for which the origin * and destination coordinates are ordered * according to the standard {@link Coordinate} ordering * * @return the primary quadedge */ public QuadEdge getPrimary() { if (orig().getCoordinate().compareTo(dest().getCoordinate()) <= 0) return this; else return sym(); }
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); } } }