Nearest neighbour
This algorithm determines the k nearest neighbours to a hurricane based on the difference in latitude and longitude. The straight line distance is calculated by using the distance formula. Each distance is then compared to determine the nearest neighbour.
Code snippet
#define REC_WINDOW 10 int rec_count = 10; float *tmp_lat = (float *) malloc(REC_WINDOW * sizeof(float)); float *z = (float *) malloc(REC_WINDOW * sizeof(float)); while(!done){ //executes for 4280 iterations
for( i = 0 ; i < rec_count ; i++ ){ z[i] = sqrtf(( (tmp_lat[i]-target_lat) * (tmp_lat[i]-target_lat) )+( (tmp_long[i]-target_long) * (tmp_long[i]-target_long) )); }
} //executes for 4280 iterations