Search in sources :

Example 51 with Point

use of com.revolsys.geometry.model.Point in project com.revolsys.open by revolsys.

the class PlanarPolygon3D method locate.

private Location locate(final Point pt, final LineString ring) {
    final LineString seq = ring;
    final LineString seqProj = project(seq, this.facingPlane);
    final Point ptProj = project(pt, this.facingPlane);
    return RayCrossingCounter.locatePointInRing(ptProj, seqProj);
}
Also used : LineString(com.revolsys.geometry.model.LineString) Point(com.revolsys.geometry.model.Point)

Example 52 with Point

use of com.revolsys.geometry.model.Point in project com.revolsys.open by revolsys.

the class PlanarPolygon3D method intersects.

public boolean intersects(final Point pt, final LineString ring) {
    final LineString seq = ring;
    final LineString seqProj = project(seq, this.facingPlane);
    final Point ptProj = project(pt, this.facingPlane);
    return Location.EXTERIOR != RayCrossingCounter.locatePointInRing(ptProj, seqProj);
}
Also used : LineString(com.revolsys.geometry.model.LineString) Point(com.revolsys.geometry.model.Point)

Example 53 with Point

use of com.revolsys.geometry.model.Point in project com.revolsys.open by revolsys.

the class Distance3DOp method computeMinDistanceLineLine.

private void computeMinDistanceLineLine(final LineString line0, final LineString line1, final boolean flip) {
    // brute force approach!
    int i = 0;
    for (final Segment segment1 : line0.segments()) {
        int j = 0;
        for (final Segment segment2 : line1.segments()) {
            final Point line1point1 = segment1.getPoint(0);
            final Point line1Point2 = segment1.getPoint(1);
            final Point line2Point1 = segment2.getPoint(0);
            final Point line2Point2 = segment2.getPoint(1);
            final double distance = CGAlgorithms3D.distanceSegmentSegment(line1point1, line1Point2, line2Point1, line2Point2);
            if (distance < this.minDistance) {
                this.minDistance = distance;
                // TODO: compute closest pts in 3D
                final Point[] closestPt = segment1.closestPoints(segment2);
                updateDistance(distance, new GeometryLocation(line0, i, closestPt[0].newPoint2D()), new GeometryLocation(line1, j, closestPt[1].newPoint2D()), flip);
            }
            if (this.isDone) {
                return;
            }
            j++;
        }
        i++;
    }
}
Also used : GeometryLocation(com.revolsys.geometry.operation.distance.GeometryLocation) Point(com.revolsys.geometry.model.Point) Point(com.revolsys.geometry.model.Point) Segment(com.revolsys.geometry.model.segment.Segment)

Example 54 with Point

use of com.revolsys.geometry.model.Point in project com.revolsys.open by revolsys.

the class Distance3DOp method computeMinDistancePolygonPoint.

private void computeMinDistancePolygonPoint(final PlanarPolygon3D polyPlane, final Point point, final boolean flip) {
    final Point pt = point.getPoint();
    final LineString shell = polyPlane.getPolygon().getShell();
    if (polyPlane.intersects(pt, shell)) {
        // point is either inside or in a hole
        final int nHole = polyPlane.getPolygon().getHoleCount();
        for (int i = 0; i < nHole; i++) {
            final LineString hole = polyPlane.getPolygon().getHole(i);
            if (polyPlane.intersects(pt, hole)) {
                computeMinDistanceLinePoint(hole, point, flip);
                return;
            }
        }
        // point is in interior of polygon
        // distance is distance to polygon plane
        final double dist = Math.abs(polyPlane.getPlane().orientedDistance(pt));
        updateDistance(dist, new GeometryLocation(polyPlane.getPolygon(), 0, pt), new GeometryLocation(point, 0, pt), flip);
    }
    // point is outside polygon, so compute distance to shell linework
    computeMinDistanceLinePoint(shell, point, flip);
}
Also used : GeometryLocation(com.revolsys.geometry.operation.distance.GeometryLocation) LineString(com.revolsys.geometry.model.LineString) Point(com.revolsys.geometry.model.Point) Point(com.revolsys.geometry.model.Point)

Example 55 with Point

use of com.revolsys.geometry.model.Point in project com.revolsys.open by revolsys.

the class Distance3DOp method intersection.

private Point intersection(final PlanarPolygon3D poly, final LineString line) {
    final LineString seq = line;
    if (seq.getVertexCount() == 0) {
        return null;
    }
    // start point of line
    Point p0 = seq.getPoint(0);
    double d0 = poly.getPlane().orientedDistance(p0);
    // for each segment in the line
    for (int i = 0; i < seq.getVertexCount() - 1; i++) {
        p0 = seq.getPoint(i);
        final Point p1 = seq.getPoint(i + 1);
        final double d1 = poly.getPlane().orientedDistance(p1);
        /**
         * If the oriented distances of the segment endpoints have the same sign,
         * the segment does not cross the plane, and is skipped.
         */
        if (d0 * d1 > 0) {
            continue;
        }
        /**
         * Compute segment-plane intersection point
         * which is then used for a point-in-polygon test.
         * The endpoint distances to the plane d0 and d1
         * give the proportional distance of the intersection point
         * along the segment.
         */
        final Point intPt = segmentPoint(p0, p1, d0, d1);
        // Point intPt = polyPlane.intersection(p0, p1, s0, s1);
        if (poly.intersects(intPt)) {
            return intPt;
        }
        // shift to next segment
        d0 = d1;
    }
    return null;
}
Also used : LineString(com.revolsys.geometry.model.LineString) Point(com.revolsys.geometry.model.Point) Point(com.revolsys.geometry.model.Point)

Aggregations

Point (com.revolsys.geometry.model.Point)669 LineString (com.revolsys.geometry.model.LineString)130 GeometryFactory (com.revolsys.geometry.model.GeometryFactory)103 Geometry (com.revolsys.geometry.model.Geometry)95 PointDoubleXY (com.revolsys.geometry.model.impl.PointDoubleXY)90 ArrayList (java.util.ArrayList)79 BoundingBox (com.revolsys.geometry.model.BoundingBox)51 Polygon (com.revolsys.geometry.model.Polygon)42 LineSegment (com.revolsys.geometry.model.segment.LineSegment)34 List (java.util.List)28 LinearRing (com.revolsys.geometry.model.LinearRing)26 PointDouble (com.revolsys.geometry.model.impl.PointDouble)22 PointDoubleXYZ (com.revolsys.geometry.model.impl.PointDoubleXYZ)19 Edge (com.revolsys.geometry.graph.Edge)18 Test (org.junit.Test)17 Punctual (com.revolsys.geometry.model.Punctual)16 Segment (com.revolsys.geometry.model.segment.Segment)15 Vertex (com.revolsys.geometry.model.vertex.Vertex)15 Record (com.revolsys.record.Record)15 Lineal (com.revolsys.geometry.model.Lineal)14