56 auto const dm = d.
norm();
59 if (dm < std::numeric_limits<T>::epsilon()) {
60 return {{{{1, 0, 0, 0}}}};
64 auto const d_xy = std::sqrt(d[0] * d[0] + d[1] * d[1]);
69 theta2 = (d[2] > 0) ? 0 : Utils::pi<T>() / 2;
75 theta2 = std::acos(d[2] / dm) / 2;
77 auto const phi = ((d[1] > 0) ? 1 : -1) * std::acos(d[0] / d_xy);
78 phi2 = phi / 2 - Utils::pi<T>() / 4;
82 auto const cos_theta2 = std::cos(theta2);
83 auto const sin_theta2 = std::sin(theta2);
84 auto const cos_phi2 = std::cos(phi2);
85 auto const sin_phi2 = std::sin(phi2);
86 return {{{{cos_theta2 * cos_phi2, -sin_theta2 * cos_phi2,
87 -sin_theta2 * sin_phi2, cos_theta2 * sin_phi2}}}};