-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathaccuracy.c
35 lines (31 loc) · 996 Bytes
/
accuracy.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include <math.h>
#include <stdlib.h>
double find_distance(int x1, int y1, int x2, int y2) {
return sqrt(pow(x1 - x2, 2) + pow(y1 - y2, 2));
}
double euclidean_single(int* whites, int length, int* whites2, int length2) {
length /= 2;
length2 /= 2;
double distances[length];
double sum = 0;
for (int i = 0; i < length; i++) {
distances[i] = 1000.f;
for (int j = 0; j < length2; j++) {
double distance = find_distance(whites[i * 2], whites[i * 2 + 1],
whites2[j * 2], whites2[j * 2 + 1]);
if (distance < distances[i]) distances[i] = distance;
}
sum += distances[i];
}
double ave = sum / (double) length;
return ave;
}
double euclidean(int* whites, int length, int* whites2, int length2) {
double one = euclidean_single(whites, length, whites2, length2);
double two = euclidean_single(whites2, length2, whites, length);
double ans = (one + two) / 2;
return (one + two) / 2;
}
int main() {
return 0;
}