package com.seewo.vcommons.helper;

/* JADX INFO: loaded from: classes.dex */
public class DegreesHelper {
    private static final int ANTI_JITTER_DEGREES = 5;
    private boolean isClockwise;
    private float mLastDegrees;
    private long mLastTimestamp;
    private int mScreenRotation;

    public DegreesHelper(int i) {
        this.mScreenRotation = i;
    }

    public void setScreenRotation(int i) {
        this.mScreenRotation = i;
    }

    public float getSuggestDegrees(float f, float f2, long j) {
        float degrees = (float) Math.toDegrees(Math.atan(f / f2));
        if (degrees < 0.0f) {
            degrees = Math.abs(degrees) > 45.0f ? 90.0f : 0.0f;
        }
        if (3 == this.mScreenRotation) {
            degrees = 90.0f - Math.abs(degrees);
        }
        if (Math.abs(degrees - this.mLastDegrees) >= 5.0f && j - this.mLastTimestamp < 120000000) {
            return this.mLastDegrees;
        }
        if (this.isClockwise) {
            float f3 = this.mLastDegrees;
            if (degrees - f3 > 0.0f && degrees - f3 < 5.0f) {
                return f3;
            }
        } else {
            float f4 = this.mLastDegrees;
            if (degrees - f4 < 0.0f && degrees - f4 > -5.0f) {
                return f4;
            }
        }
        float f5 = this.mLastDegrees;
        if (degrees - f5 >= 5.0f) {
            this.isClockwise = false;
        } else if (degrees - f5 <= -5.0f) {
            this.isClockwise = true;
        }
        this.mLastDegrees = degrees;
        this.mLastTimestamp = j;
        return degrees;
    }
}
