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