9 #include <Eigen/Eigenvalues> 20 check_required_keys({
"I_xx",
"I_yy",
"I_zz",
"I_xy",
"I_xz",
"I_yz"});
27 inertia_moment << d[
"I_xx"], d[
"I_xy"], d[
"I_xz"],
28 d[
"I_xy"], d[
"I_yy"], d[
"I_yz"],
29 d[
"I_xz"], d[
"I_yz"], d[
"I_zz"];
31 Eigen::EigenSolver<Matrix3d> solver(inertia_moment);
34 ArrayXd evals = solver.eigenvalues().real();
35 ArrayXXd evecs = solver.eigenvectors().real().transpose();
37 d[
"I_values"] = {evals(0), evals(1), evals(2)};
39 auto evecs_as_json = Json::array();
41 for (
int i = 0; i != 3; ++i)
43 auto evec = evecs.row(i);
44 evecs_as_json.push_back({evec(0), evec(1), evec(2)});
47 d[
"I_vectors"].swap(evecs_as_json);
52 evals.minCoeff(&index);
54 RowArrayXd orientation = evecs.row(index).square().unaryExpr(
57 return 0.5 * (3.0*cos2 - 1.0);
60 d[
"S_x"] = orientation(0);
61 d[
"S_y"] = orientation(1);
62 d[
"S_z"] = orientation(2);
Eigen::Array< double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor > ArrayXXd
ArrayXXd is an alias for a two-dimensional array of float numbers.
std::function< bool(const Json &)> JsonToBoolFunc
An alias for a function accepts a Json object and returns a bool.
nlohmann::json Json
Json is an alias for nlohmann::json.
Eigen::Array< double, 1, Eigen::Dynamic > RowArrayXd
RowArrayXd is an alias for a row array of float numbers.
virtual void compute_impl(Json &data, JsonToVoidFunc check_required_keys, JsonToBoolFunc check_optional_keys) override
This method overrides Updater::compute_impl.
Eigen::Array< double, Eigen::Dynamic, 1 > ArrayXd
ArrayXd is an alias for a column array of float numbers.
This file has a definition of AddMolecularOrientation class, which is a subclass of Adder class...
std::function< void(const Json &)> JsonToVoidFunc
An alias for a function accepts a Json object.
Eigen::Matrix3d Matrix3d
Matrix3d is an alias for a 3x3 matrix of float numbers.