57 auto const dm = d.
norm();
60 if (dm < std::numeric_limits<T>::epsilon()) {
61 return {{{{1, 0, 0, 0}}}};
65 auto const d_xy = std::sqrt(d[0] * d[0] + d[1] * d[1]);
70 theta2 = (d[2] > 0.) ? 0. : std::numbers::pi_v<T> / 2.;
76 theta2 = std::acos(d[2] / dm) / 2.;
78 auto const phi = ((d[1] > 0.) ? 1. : -1.) * std::acos(d[0] / d_xy);
79 phi2 = phi / 2. - std::numbers::pi_v<T> / 4.;
83 auto const cos_theta2 = std::cos(theta2);
84 auto const sin_theta2 = std::sin(theta2);
85 auto const cos_phi2 = std::cos(phi2);
86 auto const sin_phi2 = std::sin(phi2);
87 return {{{{cos_theta2 * cos_phi2, -sin_theta2 * cos_phi2,
88 -sin_theta2 * sin_phi2, cos_theta2 * sin_phi2}}}};