Hello,
You could use modulo arithmetic to calculate distance between classes
c1 = (x - y)%23
c2 = (y-x)%23
min_dist = min(c1,c2)

Since you’re comparing orientations, you might be able to use cosine similarity 2 directly without binning.