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 i2) {
        this.mScreenRotation = i2;
    }

    public float getSuggestDegrees(float f2, float f3, long j2) {
        boolean z;
        float degrees = (float) Math.toDegrees(Math.atan(f2 / f3));
        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 && j2 - this.mLastTimestamp < 120000000) {
            return this.mLastDegrees;
        }
        if (this.isClockwise) {
            float f4 = this.mLastDegrees;
            if (degrees - f4 > 0.0f && degrees - f4 < 5.0f) {
                return f4;
            }
        } else {
            float f5 = this.mLastDegrees;
            if (degrees - f5 < 0.0f && degrees - f5 > -5.0f) {
                return f5;
            }
        }
        float f6 = this.mLastDegrees;
        if (degrees - f6 < 5.0f) {
            z = degrees - f6 <= -5.0f;
            this.mLastDegrees = degrees;
            this.mLastTimestamp = j2;
            return degrees;
        }
        this.isClockwise = z;
        this.mLastDegrees = degrees;
        this.mLastTimestamp = j2;
        return degrees;
    }

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