/** * 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)); }
Vertex cross() { return (new Vertex(p.y, -p.x)); }
/** * Converts all {@link Coordinate}s in a collection to {@link Vertex}es. * @param coords the coordinates to convert * @return a List of Vertex objects */ public static List toVertices(Collection coords) { List verts = new ArrayList(); for (Iterator i = coords.iterator(); i.hasNext(); ) { Coordinate coord = (Coordinate) i.next(); verts.add(new Vertex(coord)); } return verts; }
/** * Finds a quadedge of a triangle containing a location * specified by a {@link Coordinate}, if one exists. * * @param p the Coordinate to locate * @return a quadedge on the edge of a triangle which touches or contains the location * or null if no such triangle exists */ public QuadEdge locate(Coordinate p) { return locator.locate(new Vertex(p)); }
Vertex sum(Vertex v) { return (new Vertex(p.x + v.getX(), p.y + v.getY())); }
Vertex sub(Vertex v) { return (new Vertex(p.x - v.getX(), p.y - v.getY())); }
/** * 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.z + a.getZ()) / 2.0; return new Vertex(xm, ym, zm); }
/** * 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; }
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()); }
/** * 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)); }
Vertex cross() { return (new Vertex(p.y, -p.x)); }
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); } } }
/** * Locates the edge between the given vertices, if it exists in the * subdivision. * * @param p0 a coordinate * @param p1 another coordinate * @return the edge joining the coordinates, if present * or null if no such edge exists */ public QuadEdge locate(Coordinate p0, Coordinate p1) { // find an edge containing one of the points QuadEdge e = locator.locate(new Vertex(p0)); if (e == null) return null; // normalize so that p0 is origin of base edge QuadEdge base = e; if (e.dest().getCoordinate().equals2D(p0)) base = e.sym(); // check all edges around origin of base edge QuadEdge locEdge = base; do { if (locEdge.dest().getCoordinate().equals2D(p1)) return locEdge; locEdge = locEdge.oNext(); } while (locEdge != base); return null; }
/** * Converts all {@link Coordinate}s in a collection to {@link Vertex}es. * @param coords the coordinates to convert * @return a List of Vertex objects */ public static List toVertices(Collection coords) { List verts = new ArrayList(); for (Iterator i = coords.iterator(); i.hasNext(); ) { Coordinate coord = (Coordinate) i.next(); verts.add(new Vertex(coord)); } return verts; }
/** * Finds a quadedge of a triangle containing a location * specified by a {@link Coordinate}, if one exists. * * @param p the Coordinate to locate * @return a quadedge on the edge of a triangle which touches or contains the location * or null if no such triangle exists */ public QuadEdge locate(Coordinate p) { return locator.locate(new Vertex(p)); }
Vertex sum(Vertex v) { return (new Vertex(p.x + v.getX(), p.y + v.getY())); }
Vertex sub(Vertex v) { return (new Vertex(p.x - v.getX(), p.y - v.getY())); }
/** * 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.z + a.getZ()) / 2.0; return new Vertex(xm, ym, zm); }
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()); }
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); } } }