com.vividsolutions.jts.triangulate.quadedge.Vertex类的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(8.1k)|赞(0)|评价(0)|浏览(110)

本文整理了Java中com.vividsolutions.jts.triangulate.quadedge.Vertex类的一些代码示例,展示了Vertex类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Vertex类的具体详情如下:
包路径:com.vividsolutions.jts.triangulate.quadedge.Vertex
类名称:Vertex

Vertex介绍

[英]Models a site (node) in a QuadEdgeSubdivision. The sites can be points on a line string representing a linear site.

The vertex can be considered as a vector with a norm, length, inner product, cross product, etc. Additionally, point relations (e.g., is a point to the left of a line, the circle defined by this point and two others, etc.) are also defined in this class.

It is common to want to attach user-defined data to the vertices of a subdivision. One way to do this is to subclass Vertex to carry any desired information.
[中]在四边形子分区中为站点(节点)建模。场地可以是代表线性场地的线串上的点。
顶点可以被视为具有范数、长度、内积、叉积等的向量。此外,该类中还定义了点关系(例如,直线左侧的点、由该点定义的圆以及其他两个点定义的圆等)。
通常需要将用户定义的数据附加到细分的顶点。实现这一点的一种方法是对Vertex进行子类化,以携带任何所需的信息。

代码示例

代码示例来源:origin: opentripplanner/OpenTripPlanner

this.coordinates.put(v.getCoordinate(), iV);
this.vertices.put(iV, new Vertex(iV, v.getCoordinate()));
iV++;

代码示例来源:origin: com.vividsolutions/jts

/**
 * Computes the inner or dot product
 * 
 * @param v a vertex
 * @return returns the dot product u.v
 */
double dot(Vertex v) {
  return (p.x * v.getX() + p.y * v.getY());
}

代码示例来源:origin: com.vividsolutions/jts

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;
}

代码示例来源:origin: com.vividsolutions/jts

/**
 * 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);
}

代码示例来源:origin: com.vividsolutions/jts

Vertex sum(Vertex v) {
  return (new Vertex(p.x + v.getX(), p.y + v.getY()));
}

代码示例来源:origin: com.vividsolutions/jts

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);
    }
  }
}

代码示例来源:origin: com.vividsolutions/jts

/**
 * 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;
}

代码示例来源:origin: com.vividsolutions/jts

/**
 * 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;
}

代码示例来源:origin: com.vividsolutions/jts

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();

代码示例来源:origin: matsim-org/matsim

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);

代码示例来源:origin: com.vividsolutions/jts

/**
 * Tests whether a vertex is a vertex of the outer triangle.
 * 
 * @param v
 *          the vertex to test
 * @return true if the vertex is an outer triangle vertex
 */
public boolean isFrameVertex(Vertex v) {
  if (v.equals(frameVertex[0]))
    return true;
  if (v.equals(frameVertex[1]))
    return true;
  if (v.equals(frameVertex[2]))
    return true;
  return false;
}

代码示例来源:origin: com.vividsolutions/jts

if ((v.equals(e.orig())) || (v.equals(e.dest()))) {
  break;
} else if (v.rightOf(e)) {
  e = e.sym();
} else if (!v.rightOf(e.oNext())) {
  e = e.oNext();
} else if (!v.rightOf(e.dPrev())) {
  e = e.dPrev();
} else {

代码示例来源:origin: com.vividsolutions/jts

/**
 * 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));
}

代码示例来源:origin: com.vividsolutions/jts

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());
}

代码示例来源:origin: com.vividsolutions/jts

Vertex sub(Vertex v) {
  return (new Vertex(p.x - v.getX(), p.y - v.getY()));
}

代码示例来源:origin: com.vividsolutions/jts-core

/**
 * 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);
}

代码示例来源:origin: com.vividsolutions/jts-core

/**
 * 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;
}

代码示例来源:origin: com.vividsolutions/jts-core

/**
 * 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;
}

代码示例来源:origin: com.vividsolutions/jts

/**
 * Tests whether a {@link Vertex} is the start or end vertex of a
 * {@link QuadEdge}, up to the subdivision tolerance distance.
 * 
 * @param e
 * @param v
 * @return true if the vertex is a endpoint of the edge
 */
public boolean isVertexOfEdge(QuadEdge e, Vertex v) {
  if ((v.equals(e.orig(), tolerance)) || (v.equals(e.dest(), tolerance))) {
    return true;
  }
  return false;
}

代码示例来源:origin: com.vividsolutions/jts-core

if ((v.equals(e.orig())) || (v.equals(e.dest()))) {
  break;
} else if (v.rightOf(e)) {
  e = e.sym();
} else if (!v.rightOf(e.oNext())) {
  e = e.oNext();
} else if (!v.rightOf(e.dPrev())) {
  e = e.dPrev();
} else {

相关文章