I have a significant number of objects for which I have calculated their "tilt". I want to process those objects that are close to being upright (a tilt near 0, 90, 180, or 270 degrees). I have the following brute-force code that works fine:
angle = Math.Abs(angle);
var tooTilted = (angle > 000 + maxTilt && angle < 090 - maxTilt)
|| (angle > 090 + maxTilt && angle < 180 - maxTilt)
|| (angle > 180 + maxTilt && angle < 270 - maxTilt)
|| (angle > 270 + maxTilt && angle < 360 - maxTilt);
I have this itch in the back of my head making me think there's a geometric or trigonometric trick I could be using to perform the same test more succinctly.