Method Distance
Distance(Point, Point)
Calculates the Euclidean distance between two points.
public static double Distance(Point p1, Point p2)
Parameters
Returns
- double
The Euclidean distance between
p1andp2.
Distance(IPoint, IPoint)
Calculates the Euclidean distance between two points provided via IPoint.
public static double Distance(IPoint p1, IPoint p2)
Parameters
Returns
- double
The Euclidean distance between the two points.
Distance(double, double, double, double)
Calculates the Euclidean distance between two 2D points provided as raw coordinate pairs.
public static double Distance(double x1, double y1, double x2, double y2)
Parameters
x1doubleThe X-coordinate of the first point.
y1doubleThe Y-coordinate of the first point.
x2doubleThe X-coordinate of the second point.
y2doubleThe Y-coordinate of the second point.
Returns
- double
The Euclidean distance between
x1,y1andx2,y2.
Examples
double d = Point.Distance(0, 0, 3, 4); // 5
Remarks
For maximum performance when only relative comparisons are needed, use DistanceSquared(double, double, double, double) to avoid the square-root.
- See Also