/// <summary> /// /// </summary> /// <param name="line0"></param> /// <param name="line1"></param> /// <param name="locGeom"></param> private void ComputeMinDistance(ILineString line0, ILineString line1, GeometryLocation[] locGeom) { if (line0.EnvelopeInternal.Distance(line1.EnvelopeInternal) > minDistance) { return; } ICoordinate[] coord0 = line0.Coordinates; ICoordinate[] coord1 = line1.Coordinates; // brute force approach! for (int i = 0; i < coord0.Length - 1; i++) { for (int j = 0; j < coord1.Length - 1; j++) { double dist = CGAlgorithms.DistanceLineLine( coord0[i], coord0[i + 1], coord1[j], coord1[j + 1]); if (dist < minDistance) { minDistance = dist; LineSegment seg0 = new LineSegment(coord0[i], coord0[i + 1]); LineSegment seg1 = new LineSegment(coord1[j], coord1[j + 1]); ICoordinate[] closestPt = seg0.ClosestPoints(seg1); locGeom[0] = new GeometryLocation(line0, i, closestPt[0]); locGeom[1] = new GeometryLocation(line1, j, closestPt[1]); } if (minDistance <= terminateDistance) { return; } } } }
/// <summary> /// /// </summary> /// <param name="line0"></param> /// <param name="line1"></param> /// <param name="locGeom"></param> private void ComputeMinDistance(ILineString line0, ILineString line1, GeometryLocation[] locGeom) { if (line0.EnvelopeInternal.Distance(line1.EnvelopeInternal) > _minDistance) { return; } var coord0 = line0.Coordinates; var coord1 = line1.Coordinates; // brute force approach! for (int i = 0; i < coord0.Length - 1; i++) { for (int j = 0; j < coord1.Length - 1; j++) { double dist = DistanceComputer.SegmentToSegment( coord0[i], coord0[i + 1], coord1[j], coord1[j + 1]); if (dist < _minDistance) { _minDistance = dist; var seg0 = new LineSegment(coord0[i], coord0[i + 1]); var seg1 = new LineSegment(coord1[j], coord1[j + 1]); var closestPt = seg0.ClosestPoints(seg1); locGeom[0] = new GeometryLocation(line0, i, closestPt[0]); locGeom[1] = new GeometryLocation(line1, j, closestPt[1]); } if (_minDistance <= _terminateDistance) { return; } } } }
private void ComputeMinDistanceLineLine(ILineString line0, ILineString line1, bool flip) { var coord0 = line0.Coordinates; var coord1 = line1.Coordinates; // brute force approach! for (var i = 0; i < coord0.Length - 1; i++) { for (int j = 0; j < coord1.Length - 1; j++) { var dist = CGAlgorithms3D.DistanceSegmentSegment(coord0[i], coord0[i + 1], coord1[j], coord1[j + 1]); if (dist < _minDistance) { _minDistance = dist; // TODO: compute closest pts in 3D var seg0 = new LineSegment(coord0[i], coord0[i + 1]); var seg1 = new LineSegment(coord1[j], coord1[j + 1]); var closestPt = seg0.ClosestPoints(seg1); UpdateDistance(dist, new GeometryLocation(line0, i, closestPt[0]), new GeometryLocation(line1, j, closestPt[1]), flip ); } if (_isDone) { return; } } } }
private void UpdateNearestLocationsLineLine(int i, Coordinate p0, Coordinate p1, FacetSequence facetSeq, int j, Coordinate q0, Coordinate q1, GeometryLocation[] locs) { var seg0 = new LineSegment(p0, p1); var seg1 = new LineSegment(q0, q1); var closestPt = seg0.ClosestPoints(seg1); locs[0] = new GeometryLocation(_geom, i, closestPt[0].Copy()); locs[1] = new GeometryLocation(facetSeq._geom, j, closestPt[1].Copy()); }
/// <summary> /// /// </summary> /// <param name="line0"></param> /// <param name="line1"></param> /// <param name="locGeom"></param> private void ComputeMinDistance(LineString line0, LineString line1, GeometryLocation[] locGeom) { if (line0.EnvelopeInternal.Distance(line1.EnvelopeInternal) > _minDistance) { return; } var coord0 = line0.Coordinates; var coord1 = line1.Coordinates; // brute force approach! for (int i = 0; i < coord0.Length - 1; i++) { // short-circuit if line segment is far from line var segEnv0 = new Envelope(coord0[i], coord0[i + 1]); if (segEnv0.Distance(line1.EnvelopeInternal) > _minDistance) { continue; } for (int j = 0; j < coord1.Length - 1; j++) { // short-circuit if line segments are far apart var segEnv1 = new Envelope(coord1[j], coord1[j + 1]); if (segEnv0.Distance(segEnv1) > _minDistance) { continue; } double dist = DistanceComputer.SegmentToSegment( coord0[i], coord0[i + 1], coord1[j], coord1[j + 1]); if (dist < _minDistance) { _minDistance = dist; var seg0 = new LineSegment(coord0[i], coord0[i + 1]); var seg1 = new LineSegment(coord1[j], coord1[j + 1]); var closestPt = seg0.ClosestPoints(seg1); locGeom[0] = new GeometryLocation(line0, i, closestPt[0]); locGeom[1] = new GeometryLocation(line1, j, closestPt[1]); } if (_minDistance <= _terminateDistance) { return; } } } }
private void ComputeMinDistance(LineString line0, LineString line1, DistanceLocation[] locGeom) { if (line0.Bounds.Distance(line1.Bounds) > minDistance) { return; } ICoordinateList coord0 = line0.Coordinates; ICoordinateList coord1 = line1.Coordinates; // brute force approach! int nCount0 = coord0.Count; int nCount1 = coord1.Count; for (int i = 0; i < nCount0 - 1; i++) { for (int j = 0; j < nCount1 - 1; j++) { double dist = CGAlgorithms.DistanceLineLine(coord0[i], coord0[i + 1], coord1[j], coord1[j + 1]); if (dist < minDistance) { minDistance = dist; LineSegment seg0 = new LineSegment(m_objFactory, coord0[i], coord0[i + 1]); LineSegment seg1 = new LineSegment(m_objFactory, coord1[j], coord1[j + 1]); Coordinate[] closestPt = seg0.ClosestPoints(seg1); locGeom[0] = new DistanceLocation(line0, i, closestPt[0]); locGeom[1] = new DistanceLocation(line1, j, closestPt[1]); } if (minDistance <= terminateDistance) { return; } } } }
/// <summary> /// /// </summary> /// <param name="line0"></param> /// <param name="line1"></param> /// <param name="locGeom"></param> private void ComputeMinDistance(ILineString line0, ILineString line1, GeometryLocation[] locGeom) { if (line0.EnvelopeInternal.Distance(line1.EnvelopeInternal) > _minDistance) return; IList<Coordinate> coord0 = line0.Coordinates; IList<Coordinate> coord1 = line1.Coordinates; // brute force approach! for (int i = 0; i < coord0.Count - 1; i++) { for (int j = 0; j < coord1.Count - 1; j++) { double dist = CgAlgorithms.DistanceLineLine( coord0[i], coord0[i + 1], coord1[j], coord1[j + 1]); if (dist < _minDistance) { _minDistance = dist; LineSegment seg0 = new LineSegment(coord0[i], coord0[i + 1]); LineSegment seg1 = new LineSegment(coord1[j], coord1[j + 1]); Coordinate[] closestPt = seg0.ClosestPoints(seg1); locGeom[0] = new GeometryLocation(line0, i, new Coordinate(closestPt[0])); locGeom[1] = new GeometryLocation(line1, j, new Coordinate(closestPt[1])); } if (_minDistance <= _terminateDistance) return; } } }