use of com.revolsys.geometry.model.segment.Segment in project com.revolsys.open by revolsys.
the class Distance3DOp method computeMinDistanceLinePoint.
private void computeMinDistanceLinePoint(final LineString line, final Point point, final boolean flip) {
final Point coord = point.getPoint();
// brute force approach!
int i = 0;
for (final Segment segment : line.segments()) {
final double dist = CGAlgorithms3D.distancePointSegment(coord, segment.getPoint(0), segment.getPoint(1));
if (dist < this.minDistance) {
final Point segClosestPoint = segment.closestPoint(coord);
updateDistance(dist, new GeometryLocation(line, i, segClosestPoint.newPoint2D()), new GeometryLocation(point, 0, coord), flip);
}
if (this.isDone) {
return;
}
i++;
}
}
use of com.revolsys.geometry.model.segment.Segment in project com.revolsys.open by revolsys.
the class DistanceWithPoints method computeLineLine.
private boolean computeLineLine(final LineString line1, final LineString line2) {
if (this.minDistance == Double.MAX_VALUE || line1.getBoundingBox().distance(line2.getBoundingBox()) <= this.minDistance) {
for (final Segment segment1 : line1.segments()) {
for (final Segment segment2 : line2.segments()) {
final double dist = segment1.distance(segment2);
if (dist < this.minDistance) {
this.minDistance = dist;
final Point[] closestPt = segment1.closestPoints(segment2);
this.minDistancePoint1 = closestPt[0];
this.minDistancePoint2 = closestPt[1];
if (this.minDistance <= this.terminateDistance) {
return true;
}
}
}
}
}
return false;
}
use of com.revolsys.geometry.model.segment.Segment in project com.revolsys.open by revolsys.
the class DistanceWithPoints method computePointLine.
private boolean computePointLine(final Point point, final LineString line) {
final BoundingBox boundingBox = line.getBoundingBox();
if (this.minDistance == Double.MAX_VALUE || boundingBox.distance(point) <= this.minDistance) {
for (final Segment segment : line.segments()) {
final double distance = segment.distancePoint(point);
if (distance < this.minDistance) {
this.minDistance = distance;
final Point closestPoint = segment.closestPoint(point);
this.minDistancePoint1 = point;
this.minDistancePoint2 = closestPoint;
if (this.minDistance <= this.terminateDistance) {
return true;
}
}
}
}
return false;
}
use of com.revolsys.geometry.model.segment.Segment in project com.revolsys.open by revolsys.
the class TaggedLineString method init.
private void init() {
final int vertexCount = this.parentLine.getVertexCount();
this.segs = new TaggedLineSegment[vertexCount - 1];
int i = 0;
for (final Segment segment : this.parentLine.segments()) {
final TaggedLineSegment seg = new TaggedLineSegment(segment.getPoint(0), segment.getPoint(1), this.parentLine, i);
this.segs[i] = seg;
i++;
}
}
use of com.revolsys.geometry.model.segment.Segment in project com.revolsys.open by revolsys.
the class BufferCurveMaximumDistanceFinder method computeMaxMidpointDistance.
private void computeMaxMidpointDistance(final Geometry curve) {
final PointPairDistance maxPtDist = new PointPairDistance();
final PointPairDistance minPtDist = new PointPairDistance();
for (final Segment segment : curve.segments()) {
final Point midPoint = segment.midPoint();
minPtDist.initialize();
DistanceToPointFinder.computeDistance(this.inputGeom, midPoint, minPtDist);
maxPtDist.setMaximum(minPtDist);
}
this.maxPtDist.setMaximum(maxPtDist);
}
Aggregations