public DistanceTo ( |
||
anotherPoint | Point to calculate distance to. | |
Résultat | double |
public double DistanceTo( DoublePoint anotherPoint )
{
double dx = X - anotherPoint.X;
double dy = Y - anotherPoint.Y;
return System.Math.Sqrt( dx * dx + dy * dy );
}
public AForge.DoublePoint getNearestPoint(AForge.DoublePoint point) { DoublePoint closestPoint = points[0]; double distance2P, minDistance = closestPoint.DistanceTo(point); foreach (DoublePoint p in points) { distance2P = point.DistanceTo(p); if (distance2P < minDistance) { closestPoint = p; minDistance = closestPoint.DistanceTo(point); } } return(closestPoint); }