Calculates best angle on path and approximates cardinal direction
Two suggestions:


in the cardinal function, return the number rather than setting a variable, so you shortcut all the other if statements. You could further optimize that by doing a binary rather than a linear search.
your direction function could be replaced by an array: int directions[8] = {"north", "northeast", ... };. Then the lookup is simply directions[cardinal]