本文整理汇总了C#中LineSegment.ClosestPoints方法的典型用法代码示例。如果您正苦于以下问题:C# LineSegment.ClosestPoints方法的具体用法?C# LineSegment.ClosestPoints怎么用?C# LineSegment.ClosestPoints使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LineSegment
的用法示例。
在下文中一共展示了LineSegment.ClosestPoints方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ComputeMinDistance
/// <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;
}
}
}