class OrientationUtils {

    public static int toClosestRightAngle(int degrees) {
        boolean roundUp = degrees % 90 > 45;

        int roundAppModifier = roundUp ? 1 : 0;

        return (((degrees / 90) + roundAppModifier) * 90) % 360;
    }

}