本文整理汇总了C#中LineSegment.ClosestPoint方法的典型用法代码示例。如果您正苦于以下问题:C# LineSegment.ClosestPoint方法的具体用法?C# LineSegment.ClosestPoint怎么用?C# LineSegment.ClosestPoint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LineSegment
的用法示例。
在下文中一共展示了LineSegment.ClosestPoint方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Update
public void Update(IMyEntity missile)
{
LineSegment line = new LineSegment(entity.GetPosition(), entity.GetPosition() + entity.WorldMatrix.Forward * 1e6f);
position = line.ClosestPoint(missile.GetPosition()) + missile.Physics.LinearVelocity;
linearVelocity = entity.WorldMatrix.Forward * missile.Physics.LinearVelocity.Length();
}
示例2: ComputeMinDistance
/// <summary>
///
/// </summary>
/// <param name="line"></param>
/// <param name="pt"></param>
/// <param name="locGeom"></param>
private void ComputeMinDistance(ILineString line, Point pt, GeometryLocation[] locGeom)
{
if (line.EnvelopeInternal.Distance(pt.EnvelopeInternal) > _minDistance) return;
IList<Coordinate> coord0 = line.Coordinates;
Coordinate coord = pt.Coordinate;
// brute force approach!
for (int i = 0; i < coord0.Count - 1; i++)
{
double dist = CgAlgorithms.DistancePointLine(coord, coord0[i], coord0[i + 1]);
if (dist < _minDistance)
{
_minDistance = dist;
LineSegment seg = new LineSegment(coord0[i], coord0[i + 1]);
Coordinate segClosestPoint = new Coordinate(seg.ClosestPoint(coord));
locGeom[0] = new GeometryLocation(line, i, segClosestPoint);
locGeom[1] = new GeometryLocation(pt, 0, coord);
}
if (_minDistance <= _terminateDistance) return;
}
}