Search in sources :

Example 81 with PointDoubleXY

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);
    }
}
Also used : LineSegmentDouble(com.revolsys.geometry.model.segment.LineSegmentDouble) Point(com.revolsys.geometry.model.Point) PointDoubleXY(com.revolsys.geometry.model.impl.PointDoubleXY) Point(com.revolsys.geometry.model.Point) LineSegment(com.revolsys.geometry.model.segment.LineSegment)

Example 82 with PointDoubleXY

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;
}
Also used : Geometry(com.revolsys.geometry.model.Geometry) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) Point(com.revolsys.geometry.model.Point) PointDoubleXY(com.revolsys.geometry.model.impl.PointDoubleXY) Point(com.revolsys.geometry.model.Point)

Example 83 with PointDoubleXY

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;
}
Also used : ArrayList(java.util.ArrayList) Point(com.revolsys.geometry.model.Point) PointDoubleXY(com.revolsys.geometry.model.impl.PointDoubleXY) Point(com.revolsys.geometry.model.Point)

Example 84 with PointDoubleXY

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;
}
Also used : ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) PointDoubleXY(com.revolsys.geometry.model.impl.PointDoubleXY)

Example 85 with PointDoubleXY

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;
}
Also used : Point(com.revolsys.geometry.model.Point) PointDoubleXY(com.revolsys.geometry.model.impl.PointDoubleXY)

Aggregations

PointDoubleXY (com.revolsys.geometry.model.impl.PointDoubleXY)138 Point (com.revolsys.geometry.model.Point)91 Geometry (com.revolsys.geometry.model.Geometry)36 ArrayList (java.util.ArrayList)19 BoundingBox (com.revolsys.geometry.model.BoundingBox)10 GeometryFactory (com.revolsys.geometry.model.GeometryFactory)10 List (java.util.List)9 LineString (com.revolsys.geometry.model.LineString)8 Polygon (com.revolsys.geometry.model.Polygon)6 RobustLineIntersector (com.revolsys.geometry.algorithm.RobustLineIntersector)5 LengthIndexedLine (com.revolsys.geometry.linearref.LengthIndexedLine)5 LinearLocation (com.revolsys.geometry.linearref.LinearLocation)5 LocationIndexedLine (com.revolsys.geometry.linearref.LocationIndexedLine)5 LineSegmentDouble (com.revolsys.geometry.model.segment.LineSegmentDouble)5 PointDoubleXYZ (com.revolsys.geometry.model.impl.PointDoubleXYZ)4 LineSegment (com.revolsys.geometry.model.segment.LineSegment)4 AffineTransformation (com.revolsys.geometry.model.util.AffineTransformation)4 GeometricShapeFactory (com.revolsys.geometry.util.GeometricShapeFactory)4 Vertex (com.revolsys.geometry.model.vertex.Vertex)3 KdNode (com.revolsys.geometry.index.kdtree.KdNode)2