MCPcopy Create free account
hub / github.com/PyMesh/PyMesh / fit

Method fit

tools/Wires/Parameters/IsotropicTransforms.cpp:11–31  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9using namespace PyMesh;
10
11MatrixF 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
33void IsotropicTransforms::initialize() {
34 if (m_dim == 2) {

Callers 2

process_roiMethod · 0.80
ASSERT_ISOTROPICMethod · 0.80

Calls 2

RuntimeErrorClass · 0.85
strMethod · 0.45

Tested by 1

ASSERT_ISOTROPICMethod · 0.64