/* This example shows how three different distance metrics calculate the same three points. Euclidean Distance pos1->pos2: 5.20 pos2->pos3: 5.20 pos3->pos1: 10.39 Manhattan Distance pos1->pos2: 9.00 pos2->pos3: 9.00 pos3->pos1: 18.00 Chebyshev Distance pos1->pos2: 3.00 pos2->pos3: 3.00 pos3->pos1: 6.00 */ void ExampleDistance(int argIndex, int argc, char **argv) { double pos1[3] = { 1.0, 2.0, 3.0 }; double pos2[3] = { 4.0, 5.0, 6.0 }; double pos3[3] = { 7.0, 8.0, 9.0 }; printf("Euclidean Distance\n"); printf("pos1->pos2: %.2f\n", DistanceEuclidean(pos1,0,pos2,0,3)); printf("pos2->pos3: %.2f\n", DistanceEuclidean(pos2,0,pos3,0,3)); printf("pos3->pos1: %.2f\n", DistanceEuclidean(pos3,0,pos1,0,3)); printf("\nManhattan Distance\n"); printf("pos1->pos2: %.2f\n", DistanceManhattan(pos1,0,pos2,0,3)); printf("pos2->pos3: %.2f\n", DistanceManhattan(pos2,0,pos3,0,3)); printf("pos3->pos1: %.2f\n", DistanceManhattan(pos3,0,pos1,0,3)); printf("\nChebyshev Distance\n"); printf("pos1->pos2: %.2f\n", DistanceChebyshev(pos1,0,pos2,0,3)); printf("pos2->pos3: %.2f\n", DistanceChebyshev(pos2,0,pos3,0,3)); printf("pos3->pos1: %.2f\n", DistanceChebyshev(pos3,0,pos1,0,3)); }
/** * Calculate distance (using correct metric) between 2 points. * * @param $Ncoords = number of coordinates for each point. * @param $points1 = coordinates of first point. * @param $points2 = coordinates of second point. * @param $parameters $parameters[0] is the diameter of the disk under * consideration. * @return The distance between the two points. */ double DiskDistanceMetric(int Ncoords, double *point1, double* point2, double* parameters) { return DistanceEuclidean(Ncoords, point1, point2); }