I'm trying to find the closest path to a number which can go in a cycling order, for example:
- I have the numbers 0 to 4 which could go in both directions(after 4 comes 0, before 0 comes 4).
- If I'm currently at 1 and I want to go to 2, the closest path would be going forward.
- If I'm currently at 3 and I want to go to 0, the closest path would be going forward.
- If I'm currently at 2 and I want to go to 1, the closest path would be going backwards.
That was probably clear enough after the first 1 or 2 examples.
I'd like to implement something similar in code, I can easily do that with a couple of if's etc, but I'm pretty sure there must be a better easier way to determine the closest path using math, not really sure how to though, if someone could help with approaching this that would be very useful,