| 9 | using namespace PyMesh; |
| 10 | |
| 11 | MatrixF IsotropicTransforms::fit( |
| 12 | const VectorF& from_dir, const VectorF& to_dir) const { |
| 13 | const Float tol = 1e-12; |
| 14 | |
| 15 | for (const auto& rot1 : m_rotations) { |
| 16 | for (const auto& ref : m_reflections) { |
| 17 | for (const auto& rot2 : m_rotations) { |
| 18 | VectorF dir = rot1 * ref * rot2 * from_dir; |
| 19 | Float dist = (dir - to_dir).squaredNorm(); |
| 20 | if (dist < tol) { |
| 21 | return rot1 * ref * rot2; |
| 22 | } |
| 23 | } |
| 24 | } |
| 25 | } |
| 26 | std::stringstream err_msg; |
| 27 | err_msg << "Cannot find isotropic transformation that maps <" |
| 28 | << from_dir.transpose() << "> to <" |
| 29 | << to_dir.transpose() << ">" << std::endl; |
| 30 | throw RuntimeError(err_msg.str()); |
| 31 | } |
| 32 | |
| 33 | void IsotropicTransforms::initialize() { |
| 34 | if (m_dim == 2) { |