package y;

import com.google.android.gms.maps.model.BitmapDescriptorFactory;

/* loaded from: classes.dex */
public final class u {

    /* renamed from: c, reason: collision with root package name */
    public static final b f51396c = new b(null);

    /* renamed from: d, reason: collision with root package name */
    public static final int f51397d = 8;

    /* renamed from: a, reason: collision with root package name */
    private final a[][] f51398a;

    /* renamed from: b, reason: collision with root package name */
    private final boolean f51399b = true;

    /* loaded from: classes.dex */
    public static final class a {

        /* renamed from: s, reason: collision with root package name */
        public static final C1031a f51400s = new C1031a(null);

        /* renamed from: t, reason: collision with root package name */
        public static final int f51401t = 8;

        /* renamed from: u, reason: collision with root package name */
        private static float[] f51402u;

        /* renamed from: a, reason: collision with root package name */
        private final float f51403a;

        /* renamed from: b, reason: collision with root package name */
        private final float f51404b;

        /* renamed from: c, reason: collision with root package name */
        private final float f51405c;

        /* renamed from: d, reason: collision with root package name */
        private final float f51406d;

        /* renamed from: e, reason: collision with root package name */
        private final float f51407e;

        /* renamed from: f, reason: collision with root package name */
        private final float f51408f;

        /* renamed from: g, reason: collision with root package name */
        private float f51409g;

        /* renamed from: h, reason: collision with root package name */
        private float f51410h;

        /* renamed from: i, reason: collision with root package name */
        private float f51411i;

        /* renamed from: j, reason: collision with root package name */
        private final float[] f51412j;

        /* renamed from: k, reason: collision with root package name */
        private final float f51413k;

        /* renamed from: l, reason: collision with root package name */
        private final float f51414l;

        /* renamed from: m, reason: collision with root package name */
        private final float f51415m;

        /* renamed from: n, reason: collision with root package name */
        private final float f51416n;

        /* renamed from: o, reason: collision with root package name */
        private final float f51417o;

        /* renamed from: p, reason: collision with root package name */
        private final float f51418p;

        /* renamed from: q, reason: collision with root package name */
        private final boolean f51419q;

        /* renamed from: r, reason: collision with root package name */
        private final boolean f51420r;

        /* renamed from: y.u$a$a, reason: collision with other inner class name */
        /* loaded from: classes.dex */
        public static final class C1031a {
            private C1031a() {
            }

            public /* synthetic */ C1031a(kotlin.jvm.internal.k kVar) {
                this();
            }

            /* JADX INFO: Access modifiers changed from: private */
            public final float[] b() {
                if (a.f51402u != null) {
                    float[] fArr = a.f51402u;
                    kotlin.jvm.internal.t.d(fArr);
                    return fArr;
                }
                a.f51402u = new float[91];
                float[] fArr2 = a.f51402u;
                kotlin.jvm.internal.t.d(fArr2);
                return fArr2;
            }
        }

        public a(int i10, float f10, float f11, float f12, float f13, float f14, float f15) {
            this.f51403a = f10;
            this.f51404b = f11;
            this.f51405c = f12;
            this.f51406d = f13;
            this.f51407e = f14;
            this.f51408f = f15;
            float f16 = f14 - f12;
            float f17 = f15 - f13;
            boolean z10 = true;
            boolean z11 = i10 == 1 || (i10 == 4 ? f17 > BitmapDescriptorFactory.HUE_RED : !(i10 != 5 || f17 >= BitmapDescriptorFactory.HUE_RED));
            this.f51419q = z11;
            float f18 = 1 / (f11 - f10);
            this.f51413k = f18;
            boolean z12 = 3 == i10;
            if (z12 || Math.abs(f16) < 0.001f || Math.abs(f17) < 0.001f) {
                float hypot = (float) Math.hypot(f17, f16);
                this.f51409g = hypot;
                this.f51418p = hypot * f18;
                this.f51416n = f16 / (f11 - f10);
                this.f51417o = f17 / (f11 - f10);
                this.f51412j = new float[101];
                this.f51414l = Float.NaN;
                this.f51415m = Float.NaN;
            } else {
                this.f51412j = new float[101];
                this.f51414l = f16 * (z11 ? -1 : 1);
                this.f51415m = f17 * (z11 ? 1 : -1);
                this.f51416n = z11 ? f14 : f12;
                this.f51417o = z11 ? f13 : f15;
                c(f12, f13, f14, f15);
                this.f51418p = this.f51409g * f18;
                z10 = z12;
            }
            this.f51420r = z10;
        }

        private final void c(float f10, float f11, float f12, float f13) {
            int f14;
            float f15 = f12 - f10;
            float f16 = f11 - f13;
            int length = f51400s.b().length;
            float f17 = 0.0f;
            float f18 = 0.0f;
            float f19 = 0.0f;
            int i10 = 0;
            while (i10 < length) {
                C1031a c1031a = f51400s;
                double radians = (float) Math.toRadians((i10 * 90.0d) / (c1031a.b().length - 1));
                float sin = ((float) Math.sin(radians)) * f15;
                float cos = ((float) Math.cos(radians)) * f16;
                if (i10 > 0) {
                    f17 += (float) Math.hypot(sin - f18, cos - f19);
                    c1031a.b()[i10] = f17;
                }
                i10++;
                f19 = cos;
                f18 = sin;
            }
            this.f51409g = f17;
            int length2 = f51400s.b().length;
            for (int i11 = 0; i11 < length2; i11++) {
                float[] b10 = f51400s.b();
                b10[i11] = b10[i11] / f17;
            }
            int length3 = this.f51412j.length;
            for (int i12 = 0; i12 < length3; i12++) {
                float length4 = i12 / (this.f51412j.length - 1);
                C1031a c1031a2 = f51400s;
                f14 = sm.o.f(c1031a2.b(), length4, 0, 0, 6, null);
                if (f14 >= 0) {
                    this.f51412j[i12] = f14 / (c1031a2.b().length - 1);
                } else if (f14 == -1) {
                    this.f51412j[i12] = 0.0f;
                } else {
                    int i13 = -f14;
                    int i14 = i13 - 2;
                    this.f51412j[i12] = (i14 + ((length4 - c1031a2.b()[i14]) / (c1031a2.b()[i13 - 1] - c1031a2.b()[i14]))) / (c1031a2.b().length - 1);
                }
            }
        }

        private final float o(float f10) {
            if (f10 <= BitmapDescriptorFactory.HUE_RED) {
                return BitmapDescriptorFactory.HUE_RED;
            }
            if (f10 >= 1.0f) {
                return 1.0f;
            }
            float[] fArr = this.f51412j;
            float length = f10 * (fArr.length - 1);
            int i10 = (int) length;
            float f11 = length - i10;
            float f12 = fArr[i10];
            return f12 + (f11 * (fArr[i10 + 1] - f12));
        }

        public final float d() {
            float f10 = this.f51414l * this.f51411i;
            float hypot = this.f51418p / ((float) Math.hypot(f10, (-this.f51415m) * this.f51410h));
            return this.f51419q ? (-f10) * hypot : f10 * hypot;
        }

        public final float e() {
            float f10 = this.f51414l * this.f51411i;
            float f11 = (-this.f51415m) * this.f51410h;
            float hypot = this.f51418p / ((float) Math.hypot(f10, f11));
            return this.f51419q ? (-f11) * hypot : f11 * hypot;
        }

        public final float f() {
            return this.f51416n + (this.f51414l * this.f51410h);
        }

        public final float g() {
            return this.f51417o + (this.f51415m * this.f51411i);
        }

        public final float h() {
            return this.f51416n;
        }

        public final float i() {
            return this.f51417o;
        }

        public final float j(float f10) {
            float f11 = (f10 - this.f51403a) * this.f51413k;
            float f12 = this.f51405c;
            return f12 + (f11 * (this.f51407e - f12));
        }

        public final float k(float f10) {
            float f11 = (f10 - this.f51403a) * this.f51413k;
            float f12 = this.f51406d;
            return f12 + (f11 * (this.f51408f - f12));
        }

        public final float l() {
            return this.f51403a;
        }

        public final float m() {
            return this.f51404b;
        }

        public final boolean n() {
            return this.f51420r;
        }

        public final void p(float f10) {
            double o10 = o((this.f51419q ? this.f51404b - f10 : f10 - this.f51403a) * this.f51413k) * 1.5707964f;
            this.f51410h = (float) Math.sin(o10);
            this.f51411i = (float) Math.cos(o10);
        }
    }

    /* loaded from: classes.dex */
    public static final class b {
        private b() {
        }

        public /* synthetic */ b(kotlin.jvm.internal.k kVar) {
            this();
        }
    }

    /* JADX WARN: Code restructure failed: missing block: B:11:0x0024, code lost:
    
        if (r9 != 5) goto L19;
     */
    /* JADX WARN: Code restructure failed: missing block: B:17:0x0027, code lost:
    
        if (r7 == 1) goto L15;
     */
    /* JADX WARN: Removed duplicated region for block: B:14:0x003b A[LOOP:1: B:13:0x0039->B:14:0x003b, LOOP_END] */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public u(int[] iArr, float[] fArr, float[][] fArr2) {
        int length;
        int i10;
        int length2 = fArr.length - 1;
        a[][] aVarArr = new a[length2];
        int i11 = 1;
        int i12 = 1;
        for (int i13 = 0; i13 < length2; i13++) {
            int i14 = iArr[i13];
            int i15 = 3;
            if (i14 != 0) {
                if (i14 != 1) {
                    if (i14 != 2) {
                        if (i14 != 3) {
                            i15 = 4;
                            if (i14 != 4) {
                                i15 = 5;
                            }
                        }
                    }
                    i11 = 2;
                    i12 = i11;
                    float[] fArr3 = fArr2[i13];
                    length = (fArr3.length / 2) + (fArr3.length % 2);
                    a[] aVarArr2 = new a[length];
                    for (i10 = 0; i10 < length; i10++) {
                        int i16 = i10 * 2;
                        float f10 = fArr[i13];
                        int i17 = i13 + 1;
                        float f11 = fArr[i17];
                        float[] fArr4 = fArr2[i13];
                        float f12 = fArr4[i16];
                        int i18 = i16 + 1;
                        float f13 = fArr4[i18];
                        float[] fArr5 = fArr2[i17];
                        aVarArr2[i10] = new a(i12, f10, f11, f12, f13, fArr5[i16], fArr5[i18]);
                    }
                    aVarArr[i13] = aVarArr2;
                }
                i11 = 1;
                i12 = i11;
                float[] fArr32 = fArr2[i13];
                length = (fArr32.length / 2) + (fArr32.length % 2);
                a[] aVarArr22 = new a[length];
                while (i10 < length) {
                }
                aVarArr[i13] = aVarArr22;
            }
            i12 = i15;
            float[] fArr322 = fArr2[i13];
            length = (fArr322.length / 2) + (fArr322.length % 2);
            a[] aVarArr222 = new a[length];
            while (i10 < length) {
            }
            aVarArr[i13] = aVarArr222;
        }
        this.f51398a = aVarArr;
    }

    /* JADX WARN: Code restructure failed: missing block: B:6:0x0022, code lost:
    
        if (r9 > r0[r0.length - 1][0].m()) goto L8;
     */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final void a(float f10, float[] fArr) {
        float l10;
        int i10;
        int i11 = 0;
        if (this.f51399b) {
            if (f10 >= this.f51398a[0][0].l()) {
                a[][] aVarArr = this.f51398a;
            }
            a[][] aVarArr2 = this.f51398a;
            if (f10 > aVarArr2[aVarArr2.length - 1][0].m()) {
                a[][] aVarArr3 = this.f51398a;
                i10 = aVarArr3.length - 1;
                l10 = aVarArr3[aVarArr3.length - 1][0].m();
            } else {
                l10 = this.f51398a[0][0].l();
                i10 = 0;
            }
            float f11 = f10 - l10;
            int i12 = 0;
            while (i11 < fArr.length) {
                if (this.f51398a[i10][i12].n()) {
                    fArr[i11] = this.f51398a[i10][i12].j(l10) + (this.f51398a[i10][i12].h() * f11);
                    fArr[i11 + 1] = this.f51398a[i10][i12].k(l10) + (this.f51398a[i10][i12].i() * f11);
                } else {
                    this.f51398a[i10][i12].p(l10);
                    fArr[i11] = this.f51398a[i10][i12].f() + (this.f51398a[i10][i12].d() * f11);
                    fArr[i11 + 1] = this.f51398a[i10][i12].g() + (this.f51398a[i10][i12].e() * f11);
                }
                i11 += 2;
                i12++;
            }
            return;
        }
        if (f10 < this.f51398a[0][0].l()) {
            f10 = this.f51398a[0][0].l();
        }
        a[][] aVarArr4 = this.f51398a;
        if (f10 > aVarArr4[aVarArr4.length - 1][0].m()) {
            a[][] aVarArr5 = this.f51398a;
            f10 = aVarArr5[aVarArr5.length - 1][0].m();
        }
        int length = this.f51398a.length;
        boolean z10 = false;
        for (int i13 = 0; i13 < length; i13++) {
            int i14 = 0;
            int i15 = 0;
            while (i14 < fArr.length) {
                if (f10 <= this.f51398a[i13][i15].m()) {
                    if (this.f51398a[i13][i15].n()) {
                        fArr[i14] = this.f51398a[i13][i15].j(f10);
                        fArr[i14 + 1] = this.f51398a[i13][i15].k(f10);
                    } else {
                        this.f51398a[i13][i15].p(f10);
                        fArr[i14] = this.f51398a[i13][i15].f();
                        fArr[i14 + 1] = this.f51398a[i13][i15].g();
                    }
                    z10 = true;
                }
                i14 += 2;
                i15++;
            }
            if (z10) {
                return;
            }
        }
    }

    public final void b(float f10, float[] fArr) {
        if (f10 < this.f51398a[0][0].l()) {
            f10 = this.f51398a[0][0].l();
        } else {
            a[][] aVarArr = this.f51398a;
            if (f10 > aVarArr[aVarArr.length - 1][0].m()) {
                a[][] aVarArr2 = this.f51398a;
                f10 = aVarArr2[aVarArr2.length - 1][0].m();
            }
        }
        int length = this.f51398a.length;
        boolean z10 = false;
        for (int i10 = 0; i10 < length; i10++) {
            int i11 = 0;
            int i12 = 0;
            while (i11 < fArr.length) {
                if (f10 <= this.f51398a[i10][i12].m()) {
                    if (this.f51398a[i10][i12].n()) {
                        fArr[i11] = this.f51398a[i10][i12].h();
                        fArr[i11 + 1] = this.f51398a[i10][i12].i();
                    } else {
                        this.f51398a[i10][i12].p(f10);
                        fArr[i11] = this.f51398a[i10][i12].d();
                        fArr[i11 + 1] = this.f51398a[i10][i12].e();
                    }
                    z10 = true;
                }
                i11 += 2;
                i12++;
            }
            if (z10) {
                return;
            }
        }
    }
}
