class l {
  static fromAngles([o, a, n]) {
    o *= Math.PI / 360, a *= Math.PI / 360, n *= Math.PI / 360;
    const s = Math.sin(o), e = Math.cos(o), r = Math.sin(a), h = Math.cos(a), M = Math.sin(n), t = Math.cos(n);
    return [
      e * h * t + s * r * M,
      s * h * t - e * r * M,
      e * r * t + s * h * M,
      e * h * M - s * r * t
    ];
  }
  static toAngles([o, a, n, s]) {
    return [
      Math.atan2(2 * (o * a + n * s), 1 - 2 * (a * a + n * n)) * 180 / Math.PI,
      Math.asin(Math.max(-1, Math.min(1, 2 * (o * n - s * a)))) * 180 / Math.PI,
      Math.atan2(2 * (o * s + a * n), 1 - 2 * (n * n + s * s)) * 180 / Math.PI
    ];
  }
  static interpolateAngles(o, a) {
    const n = l.interpolate(l.fromAngles(o), l.fromAngles(a));
    return (s) => l.toAngles(n(s));
  }
  static interpolateLinear([o, a, n, s], [e, r, h, M]) {
    e -= o, r -= a, h -= n, M -= s;
    const t = new Array(4);
    return (c) => {
      const i = Math.hypot(t[0] = o + e * c, t[1] = a + r * c, t[2] = n + h * c, t[3] = s + M * c);
      return t[0] /= i, t[1] /= i, t[2] /= i, t[3] /= i, t;
    };
  }
  static interpolate([o, a, n, s], [e, r, h, M]) {
    let t = o * e + a * r + n * h + s * M;
    if (t < 0 && (e = -e, r = -r, h = -h, M = -M, t = -t), t > 0.9995) return l.interpolateLinear([o, a, n, s], [e, r, h, M]);
    const c = Math.acos(Math.max(-1, Math.min(1, t))), i = new Array(4), u = Math.hypot(e -= o * t, r -= a * t, h -= n * t, M -= s * t);
    return e /= u, r /= u, h /= u, M /= u, (f) => {
      const m = c * f, p = Math.sin(m), A = Math.cos(m);
      return i[0] = o * A + e * p, i[1] = a * A + r * p, i[2] = n * A + h * p, i[3] = s * A + M * p, i;
    };
  }
}
export {
  l as default
};
