Click or drag to resize
Accord.NET (logo)

EuclideanDistance Method (Double, Double, Double, Double)

Gets the Euclidean distance between two points. Note: this function is dangerous as it is too easy to invert its arguments by mistake. Please consider using the Tuple<double, double> overload instead.

Namespace:  Accord.Math.Distances
Assembly:  Accord.Math (in Accord.Math.dll) Version: 3.8.0
Syntax
public double Distance(
	double vector1x,
	double vector1y,
	double vector2x,
	double vector2y
)
Request Example View Source

Parameters

vector1x
Type: SystemDouble
The first coordinate of first point in space.
vector1y
Type: SystemDouble
The second coordinate of first point in space.
vector2x
Type: SystemDouble
The first coordinate of second point in space.
vector2y
Type: SystemDouble
The second coordinate of second point in space.

Return Value

Type: Double
The Euclidean distance between x and y.
Examples
// Let's say the coordinates of the first 2D vector are
double x1 = 1.5;
double y1 = -2.1;

// And then the coordinates of the second 2D vector are:
double x2 = 4;
double y2 = 1;

// The euclidean distance between (x1, y1) and (x2, y2) are:
double a = Distance.Euclidean(x1, y1, x2, y2); // should be ~3.9824615503479754

// This is equivalent to 
double b = Distance.Euclidean(new[] { x1, y1 }, new[] { x2, y2 });
See Also