30 const auto coshEtaInv = 1 / std::cosh(eta);
33 std::sin(phi) * coshEtaInv,
49 const auto cosTheta =
std::cos(theta);
50 const auto sinTheta = std::sin(theta);
53 std::sin(phi) * sinTheta,
65 template <
typename InputVector>
67 const Eigen::MatrixBase<InputVector>& direction) {
68 EIGEN_STATIC_ASSERT_FIXED_SIZE(InputVector);
69 EIGEN_STATIC_ASSERT_VECTOR_ONLY(InputVector);
70 static_assert(3 <= InputVector::RowsAtCompileTime,
71 "Direction vector must be at least three-dimensional.");
73 using OutputVector =
typename InputVector::PlainObject;
76 OutputVector unitU = OutputVector::Zero();
78 unitU[0] = -direction[1];
79 unitU[1] = direction[0];
80 const auto scale = unitU.template head<2>().norm();
89 unitU.template head<2>() /= scale;
107 template <
typename InputVector>
109 const Eigen::MatrixBase<InputVector>& direction) {
110 EIGEN_STATIC_ASSERT_FIXED_SIZE(InputVector);
111 EIGEN_STATIC_ASSERT_VECTOR_ONLY(InputVector);
112 static_assert(3 <= InputVector::RowsAtCompileTime,
113 "Direction vector must be at least three-dimensional.");
115 using OutputVector =
typename InputVector::PlainObject;
117 std::pair<OutputVector, OutputVector> unitVectors;
119 unitVectors.second = direction.cross(unitVectors.first);
120 unitVectors.second.normalize();