use of com.revolsys.geometry.model.impl.PointDoubleXY in project com.revolsys.open by revolsys.
the class SegmentPointComparatorFullTest method checkSegment.
private void checkSegment(final double x, final double y) {
final Point seg0 = new PointDoubleXY(0, 0);
final Point seg1 = new PointDoubleXY(x, y);
final LineSegment seg = new LineSegmentDouble(seg0, seg1);
for (int i = 0; i < 4; i++) {
final double dist = i;
final double gridSize = 1;
checkPointsAtDistance(seg, dist, dist + 1.0 * gridSize);
checkPointsAtDistance(seg, dist, dist + 2.0 * gridSize);
checkPointsAtDistance(seg, dist, dist + 3.0 * gridSize);
checkPointsAtDistance(seg, dist, dist + 4.0 * gridSize);
}
}
use of com.revolsys.geometry.model.impl.PointDoubleXY in project com.revolsys.open by revolsys.
the class PolygonUnionPerfTest method newPolygons.
/**
* Creates a grid of circles with a small percentage of overlap
* in both directions.
* This approximated likely real-world cases well,
* and seems to produce
* close to worst-case performance for the Iterated algorithm.
*
* Sample times:
* 1000 items/100 pts - Cascaded: 2718 ms, Iterated 150 s
*
* @param nItems
* @param size
* @param nPts
* @return
*/
List newPolygons(final int nItems, final double size, final int nPts) {
// between 0 and 1
final double overlapPct = 0.2;
final int nCells = (int) Math.sqrt(nItems);
final List geoms = new ArrayList();
// double width = env.getWidth();
final double width = nCells * (1 - overlapPct) * size;
// this results in many final polys
final double height = nCells * 2 * size;
// this results in a single final polygon
// double height = width;
final double xInc = width / nCells;
final double yInc = height / nCells;
for (int i = 0; i < nCells; i++) {
for (int j = 0; j < nCells; j++) {
final Point base = new PointDoubleXY(i * xInc, j * yInc);
final Geometry poly = newPolygon(base, size, nPts);
geoms.add(poly);
// System.out.println(poly);
}
}
return geoms;
}
use of com.revolsys.geometry.model.impl.PointDoubleXY in project com.revolsys.open by revolsys.
the class DelaunayPerfTest method randomPoints.
List<Point> randomPoints(final int nPts) {
final List<Point> pts = new ArrayList<>();
for (int i = 0; i < nPts; i++) {
final double x = SIDE_LEN * Math.random();
final double y = SIDE_LEN * Math.random();
pts.add(new PointDoubleXY(x, y));
}
return pts;
}
use of com.revolsys.geometry.model.impl.PointDoubleXY in project com.revolsys.open by revolsys.
the class VoronoiPerfTest method randomPoints.
List randomPoints(final int nPts) {
final List pts = new ArrayList();
final int nSide = (int) Math.sqrt(nPts) + 1;
for (int i = 0; i < nSide; i++) {
for (int j = 0; j < nSide; j++) {
final double x = i * SIDE_LEN + SIDE_LEN * Math.random();
final double y = j * SIDE_LEN + SIDE_LEN * Math.random();
pts.add(new PointDoubleXY(x, y));
}
}
return pts;
}
use of com.revolsys.geometry.model.impl.PointDoubleXY in project com.revolsys.open by revolsys.
the class DistanceLineLineStressTest method randomDisjointCollinearSegments.
private static Point[] randomDisjointCollinearSegments() {
final double slope = randGen.nextDouble();
final Point[] seg = new Point[4];
final double gap = 1;
final double x1 = 10;
final double x2 = x1 + gap;
final double x3 = x1 + gap + 10;
seg[0] = new PointDoubleXY(0, 0);
seg[1] = new PointDoubleXY(x1, slope * x1);
seg[2] = new PointDoubleXY(x2, slope * x2);
seg[3] = new PointDoubleXY(x3, slope * x3);
return seg;
}
Aggregations