use of com.revolsys.geometry.model.Point in project com.revolsys.open by revolsys.
the class ConformingDelaunayTriangulator method findNonGabrielPoint.
/**
* Given a set of points stored in the kd-tree and a line segment defined by
* two points in this set, finds a {@link Coordinates} in the circumcircle of
* the line segment, if one exists. This is called the Gabriel point - if none
* exists then the segment is said to have the Gabriel condition. Uses the
* heuristic of finding the non-Gabriel point closest to the midpoint of the
* segment.
*
* @param p
* start of the line segment
* @param q
* end of the line segment
* @return a point which is non-Gabriel
* or null if no point is non-Gabriel
*/
private Point findNonGabrielPoint(final LineSegmentDoubleData seg) {
final Point p = seg.getPoint(0);
final Point q = seg.getPoint(1);
// Find the mid point on the line and compute the radius of enclosing circle
final Point midPt = new PointDoubleXY((p.getX() + q.getX()) / 2.0, (p.getY() + q.getY()) / 2.0);
final double segRadius = p.distancePoint(midPt);
// compute envelope of circumcircle
final BoundingBox env = midPt.getBoundingBox().expand(segRadius);
// Find all points in envelope
final List result = this.pointIndex.getItems(env);
// For each point found, test if it falls strictly in the circle
// find closest point
Point closestNonGabriel = null;
double minDist = Double.MAX_VALUE;
for (final Iterator i = result.iterator(); i.hasNext(); ) {
final KdNode nextNode = (KdNode) i.next();
final Point testPt = nextNode;
// ignore segment endpoints
if (testPt.equals(2, p) || testPt.equals(2, q)) {
continue;
}
final double testRadius = midPt.distancePoint(testPt);
if (testRadius < segRadius) {
// double testDist = seg.distance(testPt);
final double testDist = testRadius;
if (closestNonGabriel == null || testDist < minDist) {
closestNonGabriel = testPt;
minDist = testDist;
}
}
}
return closestNonGabriel;
}
use of com.revolsys.geometry.model.Point in project com.revolsys.open by revolsys.
the class ConvexHull method cleanRing.
/**
*@param vertices the vertices of a linear ring, which may or may not be
* flattened (i.e. vertices collinear)
*@return the coordinates with unnecessary (collinear) vertices
* removed
*/
private static LineStringEditor cleanRing(final GeometryFactory geometryFactory, final List<Point> points) {
final int count = points.size();
final LineStringEditor cleanedRing = new LineStringEditor(geometryFactory, count);
Point previousDistinctPoint = null;
for (int i = 0; i <= count - 2; i++) {
final Point currentPoint = points.get(i);
final Point nextPoint = points.get(i + 1);
if (currentPoint.equals(nextPoint)) {
} else if (previousDistinctPoint != null && isBetween(previousDistinctPoint, currentPoint, nextPoint)) {
} else {
cleanedRing.appendVertex(currentPoint);
previousDistinctPoint = currentPoint;
}
}
cleanedRing.appendVertex(points.get(count - 1));
return cleanedRing;
}
use of com.revolsys.geometry.model.Point in project com.revolsys.open by revolsys.
the class NonEncroachingSplitPointFinder method projectedSplitPoint.
/**
* Computes a split point which is the projection of the encroaching point on the segment
*
* @param seg
* @param encroachPt
* @return a split point on the segment
*/
public static Point projectedSplitPoint(final LineSegmentDoubleData seg, final Point encroachPt) {
final LineSegment lineSeg = seg;
final Point projPt = lineSeg.project(encroachPt);
return projPt;
}
use of com.revolsys.geometry.model.Point in project com.revolsys.open by revolsys.
the class QuadEdgeConformingDelaunayTinBuilder method initVertices.
private void initVertices(final Geometry geom) {
for (final Point point : geom.vertices()) {
final ConstraintVertex vertex = new ConstraintVertex(point);
this.constraintVertexMap.put(vertex, vertex);
}
}
use of com.revolsys.geometry.model.Point in project com.revolsys.open by revolsys.
the class QuadEdgeConformingDelaunayTinBuilder method unique.
public static PointList unique(final Iterable<? extends Point> points, final int vertexCount) {
final Point[] pointArray = new Point[vertexCount];
int vertexIndex = 0;
for (final Point point : points) {
pointArray[vertexIndex++] = point.newPoint();
}
Arrays.sort(pointArray);
final PointList coordList = new PointList(pointArray, false);
return coordList;
}
Aggregations