This is a follow-up to an earlier project log. I decided to divide the celestial sphere into 1280 patches (20*4³) instead of the 2880 I chose to use earlier, but that's not really important.
Important is that this actually works as intended. My goal was to be able to have a center patch whose centroid is closest to the telescope's viewing direction and a list of the corresponding neighbour patches. The distance between the viewing direction and the centroid of a patch is the great-circle distance, and some hysteresis (1°) is introduced to avoid jumping back and forth near the boundary between two patches.
A patch manager class keeps track of all this and has an update method with the only argument being the current viewing direction. It calculates the distance between the center patch and the viewing direction and the distances between the neighbours and the viewing direction. If a neighbour's distance is smaller than the center's distance, this neighbour becomes the new center. This is repeated until no more improvement was made.
With the current patch size, traversing from the zenith to the horizon is done in 10 steps and takes about 100 ms (10 ms per step). That includes all the great-circle distance comparisons and reading from the SD card for fetching the next set of neighbours. This is surely fast enough for "normal" hand-operated usage.