package androidx.constraintlayout.motion.widget;

import android.view.View;
import java.util.Arrays;
import java.util.LinkedHashMap;

/* JADX INFO: compiled from: MotionPaths.java */
/* JADX INFO: loaded from: classes.dex */
class k implements Comparable<k> {

    /* JADX INFO: renamed from: u, reason: collision with root package name */
    static String[] f1215u = {"position", "x", "y", "width", "height", "pathRotate"};

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    l.b f1216e;

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    float f1218g;

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    float f1219h;

    /* JADX INFO: renamed from: i, reason: collision with root package name */
    float f1220i;

    /* JADX INFO: renamed from: j, reason: collision with root package name */
    float f1221j;

    /* JADX INFO: renamed from: k, reason: collision with root package name */
    float f1222k;

    /* JADX INFO: renamed from: l, reason: collision with root package name */
    float f1223l;

    /* JADX INFO: renamed from: n, reason: collision with root package name */
    int f1225n;

    /* JADX INFO: renamed from: o, reason: collision with root package name */
    int f1226o;

    /* JADX INFO: renamed from: p, reason: collision with root package name */
    g f1227p;

    /* JADX INFO: renamed from: q, reason: collision with root package name */
    LinkedHashMap<String, androidx.constraintlayout.widget.a> f1228q;

    /* JADX INFO: renamed from: r, reason: collision with root package name */
    int f1229r;

    /* JADX INFO: renamed from: s, reason: collision with root package name */
    double[] f1230s;

    /* JADX INFO: renamed from: t, reason: collision with root package name */
    double[] f1231t;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    int f1217f = 0;

    /* JADX INFO: renamed from: m, reason: collision with root package name */
    float f1224m = Float.NaN;

    public k() {
        int i3 = d.f1152a;
        this.f1225n = i3;
        this.f1226o = i3;
        this.f1227p = null;
        this.f1228q = new LinkedHashMap<>();
        this.f1229r = 0;
        this.f1230s = new double[18];
        this.f1231t = new double[18];
    }

    @Override // java.lang.Comparable
    /* JADX INFO: renamed from: a, reason: merged with bridge method [inline-methods] */
    public int compareTo(k kVar) {
        return Float.compare(this.f1219h, kVar.f1219h);
    }

    void b(double d3, int[] iArr, double[] dArr, float[] fArr, double[] dArr2, float[] fArr2) {
        float f3;
        float f4;
        float f5 = this.f1220i;
        float f6 = this.f1221j;
        float f7 = this.f1222k;
        float f8 = this.f1223l;
        float f9 = 0.0f;
        float f10 = 0.0f;
        float f11 = 0.0f;
        float f12 = 0.0f;
        for (int i3 = 0; i3 < iArr.length; i3++) {
            float f13 = (float) dArr[i3];
            float f14 = (float) dArr2[i3];
            int i4 = iArr[i3];
            if (i4 == 1) {
                f5 = f13;
                f9 = f14;
            } else if (i4 == 2) {
                f6 = f13;
                f11 = f14;
            } else if (i4 == 3) {
                f7 = f13;
                f10 = f14;
            } else if (i4 == 4) {
                f8 = f13;
                f12 = f14;
            }
        }
        float f15 = (f10 / 2.0f) + f9;
        float fCos = (f12 / 2.0f) + f11;
        g gVar = this.f1227p;
        if (gVar != null) {
            float[] fArr3 = new float[2];
            float[] fArr4 = new float[2];
            gVar.b(d3, fArr3, fArr4);
            float f16 = fArr3[0];
            float f17 = fArr3[1];
            float f18 = fArr4[0];
            float f19 = fArr4[1];
            double d4 = f5;
            float f20 = f11;
            double d5 = f6;
            f3 = f7;
            float fSin = (float) ((((double) f16) + (Math.sin(d5) * d4)) - ((double) (f7 / 2.0f)));
            float fCos2 = (float) ((((double) f17) - (d4 * Math.cos(d5))) - ((double) (f8 / 2.0f)));
            double d6 = f9;
            double d7 = f20;
            float fSin2 = (float) (((double) f18) + (Math.sin(d5) * d6) + (Math.cos(d5) * d7));
            fCos = (float) ((((double) f19) - (d6 * Math.cos(d5))) + (Math.sin(d5) * d7));
            f5 = fSin;
            f6 = fCos2;
            f15 = fSin2;
            f4 = 2.0f;
        } else {
            f3 = f7;
            f4 = 2.0f;
        }
        fArr[0] = f5 + (f3 / f4) + 0.0f;
        fArr[1] = f6 + (f8 / f4) + 0.0f;
        fArr2[0] = f15;
        fArr2[1] = fCos;
    }

    /* JADX WARN: Multi-variable type inference failed */
    void c(float f3, View view, int[] iArr, double[] dArr, double[] dArr2, double[] dArr3, boolean z2) {
        float f4;
        boolean z3;
        boolean z4;
        float f5;
        float f6 = this.f1220i;
        float f7 = this.f1221j;
        float f8 = this.f1222k;
        float f9 = this.f1223l;
        if (iArr.length != 0 && this.f1230s.length <= iArr[iArr.length - 1]) {
            int i3 = iArr[iArr.length - 1] + 1;
            this.f1230s = new double[i3];
            this.f1231t = new double[i3];
        }
        Arrays.fill(this.f1230s, Double.NaN);
        for (int i4 = 0; i4 < iArr.length; i4++) {
            this.f1230s[iArr[i4]] = dArr[i4];
            this.f1231t[iArr[i4]] = dArr2[i4];
        }
        float f10 = Float.NaN;
        int i5 = 0;
        float f11 = 0.0f;
        float f12 = 0.0f;
        float f13 = 0.0f;
        float f14 = 0.0f;
        while (true) {
            double[] dArr4 = this.f1230s;
            if (i5 >= dArr4.length) {
                break;
            }
            if (Double.isNaN(dArr4[i5]) && (dArr3 == null || dArr3[i5] == 0.0d)) {
                f5 = f10;
            } else {
                double d3 = dArr3 != null ? dArr3[i5] : 0.0d;
                if (!Double.isNaN(this.f1230s[i5])) {
                    d3 = this.f1230s[i5] + d3;
                }
                f5 = f10;
                float f15 = (float) d3;
                float f16 = (float) this.f1231t[i5];
                if (i5 == 1) {
                    f10 = f5;
                    f6 = f15;
                    f11 = f16;
                } else if (i5 == 2) {
                    f10 = f5;
                    f7 = f15;
                    f12 = f16;
                } else if (i5 == 3) {
                    f10 = f5;
                    f8 = f15;
                    f13 = f16;
                } else if (i5 == 4) {
                    f10 = f5;
                    f9 = f15;
                    f14 = f16;
                } else if (i5 == 5) {
                    f10 = f15;
                }
                i5++;
            }
            f10 = f5;
            i5++;
        }
        float f17 = f10;
        g gVar = this.f1227p;
        if (gVar != null) {
            float[] fArr = new float[2];
            float[] fArr2 = new float[2];
            gVar.b(f3, fArr, fArr2);
            float f18 = fArr[0];
            float f19 = fArr[1];
            float f20 = fArr2[0];
            float f21 = fArr2[1];
            double d4 = f6;
            double d5 = f7;
            float fSin = (float) ((((double) f18) + (Math.sin(d5) * d4)) - ((double) (f8 / 2.0f)));
            f4 = f9;
            float fCos = (float) ((((double) f19) - (Math.cos(d5) * d4)) - ((double) (f9 / 2.0f)));
            double d6 = f11;
            double d7 = f12;
            float fSin2 = (float) (((double) f20) + (Math.sin(d5) * d6) + (Math.cos(d5) * d4 * d7));
            float fCos2 = (float) ((((double) f21) - (d6 * Math.cos(d5))) + (d4 * Math.sin(d5) * d7));
            if (dArr2.length >= 2) {
                z3 = false;
                dArr2[0] = fSin2;
                z4 = true;
                dArr2[1] = fCos2;
            } else {
                z3 = false;
                z4 = true;
            }
            if (!Float.isNaN(f17)) {
                view.setRotation((float) (((double) f17) + Math.toDegrees(Math.atan2(fCos2, fSin2))));
            }
            f6 = fSin;
            f7 = fCos;
        } else {
            f4 = f9;
            z3 = false;
            z4 = true;
            if (!Float.isNaN(f17)) {
                view.setRotation((float) (((double) 0.0f) + ((double) f17) + Math.toDegrees(Math.atan2(f12 + (f14 / 2.0f), f11 + (f13 / 2.0f)))));
            }
        }
        if (view instanceof c) {
            ((c) view).a(f6, f7, f8 + f6, f7 + f4);
            return;
        }
        float f22 = f6 + 0.5f;
        int i6 = (int) f22;
        float f23 = f7 + 0.5f;
        int i7 = (int) f23;
        int i8 = (int) (f22 + f8);
        int i9 = (int) (f23 + f4);
        int i10 = i8 - i6;
        int i11 = i9 - i7;
        if (i10 != view.getMeasuredWidth() || i11 != view.getMeasuredHeight()) {
            z3 = z4;
        }
        if (z3 || z2) {
            view.measure(View.MeasureSpec.makeMeasureSpec(i10, 1073741824), View.MeasureSpec.makeMeasureSpec(i11, 1073741824));
        }
        view.layout(i6, i7, i8, i9);
    }
}
