float normalized_x = normalize(x - corrections[0], mins[0], maxes[0]);
float normalized_y = normalize(y - corrections[1], mins[1], maxes[1]);
int compass_heading = (int)(atan2(normalized_y, normalized_x) * 180.0 / 3.14159);
// compass_heading is between -180 and +180 since atan2 returns -pi to +pi
// this translates it to be between 0 and 360
compass_heading += 180;
// We add 15 to account to the zero position being 0 +/- 15 degrees.
// mod by 360 to keep it within a circle
// divide by 30 to find which pixel corresponding pie slice it's in
int direction_index = ((compass_heading + 15) % 360) / 30;