package com.seewo.factoryaging.opengl3d.h;

/* JADX INFO: compiled from: Quaternion.java */
/* JADX INFO: loaded from: classes.dex */
public class k {
    private float a;
    private float b;
    private float c;
    private float d;

    public k(float f, float f2, float f3, float f4) {
        this.a = f;
        this.b = f2;
        this.c = f3;
        this.d = f4;
        b();
    }

    public static k a(k kVar, k kVar2, float f) {
        k kVar3 = new k(0.0f, 0.0f, 0.0f, 1.0f);
        float f2 = kVar.d;
        float f3 = kVar2.d;
        float f4 = kVar.a;
        float f5 = kVar2.a;
        float f6 = (f2 * f3) + (f4 * f5);
        float f7 = kVar.b;
        float f8 = kVar2.b;
        float f9 = kVar.c;
        float f10 = kVar2.c;
        float f11 = 1.0f - f;
        if (f6 + (f7 * f8) + (f9 * f10) < 0.0f) {
            kVar3.d = (f2 * f11) + ((-f3) * f);
            kVar3.a = (f4 * f11) + ((-f5) * f);
            kVar3.b = (f7 * f11) + ((-f8) * f);
            kVar3.c = (f11 * f9) + (f * (-f10));
        } else {
            kVar3.d = (f2 * f11) + (f3 * f);
            kVar3.a = (f4 * f11) + (f5 * f);
            kVar3.b = (f7 * f11) + (f8 * f);
            kVar3.c = (f11 * f9) + (f * f10);
        }
        kVar3.b();
        return kVar3;
    }

    public void b() {
        float f = this.d;
        float f2 = this.a;
        float f3 = (f * f) + (f2 * f2);
        float f4 = this.b;
        float f5 = f3 + (f4 * f4);
        float f6 = this.c;
        float fSqrt = (float) Math.sqrt(f5 + (f6 * f6));
        this.d /= fSqrt;
        this.a /= fSqrt;
        this.b /= fSqrt;
        this.c /= fSqrt;
    }

    public float[] c(float[] fArr) {
        float f = this.a;
        float f2 = this.b;
        float f3 = f * f2;
        float f4 = this.c;
        float f5 = f * f4;
        float f6 = this.d;
        float f7 = f * f6;
        float f8 = f2 * f4;
        float f9 = f2 * f6;
        float f10 = f6 * f4;
        float f11 = f * f;
        float f12 = f2 * f2;
        float f13 = f4 * f4;
        fArr[0] = 1.0f - ((f12 + f13) * 2.0f);
        fArr[1] = (f3 - f10) * 2.0f;
        fArr[2] = (f5 + f9) * 2.0f;
        fArr[3] = 0.0f;
        fArr[4] = (f3 + f10) * 2.0f;
        fArr[5] = 1.0f - ((f13 + f11) * 2.0f);
        fArr[6] = (f8 - f7) * 2.0f;
        fArr[7] = 0.0f;
        fArr[8] = (f5 - f9) * 2.0f;
        fArr[9] = (f8 + f7) * 2.0f;
        fArr[10] = 1.0f - ((f11 + f12) * 2.0f);
        fArr[11] = 0.0f;
        fArr[12] = 0.0f;
        fArr[13] = 0.0f;
        fArr[14] = 0.0f;
        fArr[15] = 1.0f;
        return fArr;
    }

    public String toString() {
        return "Quaternion{x=" + this.a + ", y=" + this.b + ", z=" + this.c + ", w=" + this.d + '}';
    }
}
