class OrientationUtils {

    public static int computeDisplayOrientation(int screenRotationDegrees,
                                                int cameraRotationDegrees,
                                                boolean cameraIsMirrored) {
        int degrees = OrientationUtils.toClosestRightAngle(screenRotationDegrees);

        if (cameraIsMirrored) {
            degrees = (cameraRotationDegrees + degrees) % 360;
            degrees = (360 - degrees) % 360;
        } else {
            degrees = (cameraRotationDegrees - degrees + 360) % 360;
        }

        return degrees;
    }

}