Added SVD decomposition to transformation debug imgui dialog

This commit is contained in:
enricoturri1966 2023-02-02 10:00:57 +01:00
parent 22ccb56578
commit e3a20bf6c4

View File

@ -2824,7 +2824,7 @@ void Selection::render_debug_window() const
} }
static int current_method_idx = 0; static int current_method_idx = 0;
ImGui::Combo("Decomposition method", &current_method_idx, "computeRotationScaling\0computeScalingRotation\0"); ImGui::Combo("Decomposition method", &current_method_idx, "computeRotationScaling\0computeScalingRotation\0SVD\0");
const GLVolume& v = *get_volume(current_vol_idx); const GLVolume& v = *get_volume(current_vol_idx);
@ -2844,23 +2844,56 @@ void Selection::render_debug_window() const
ImGui::EndGroup(); ImGui::EndGroup();
}; };
auto add_matrices_set = [add_matrix](const std::string& name, const Transform3d& m, size_t method) { auto add_matrices_set = [&imgui, add_matrix](const std::string& name, const Transform3d& m, size_t method) {
static unsigned int counter = 0; static unsigned int counter = 0;
++counter; ++counter;
if (ImGui::CollapsingHeader(name.c_str(), ImGuiTreeNodeFlags_DefaultOpen)) { if (ImGui::CollapsingHeader(name.c_str(), ImGuiTreeNodeFlags_DefaultOpen)) {
add_matrix("Full", m, 4); add_matrix("Full", m, 4);
Matrix3d rotation; if (method == 0 || method == 1) {
Matrix3d scale; Matrix3d rotation;
if (method == 0) Matrix3d scale;
m.computeRotationScaling(&rotation, &scale); if (method == 0)
else m.computeRotationScaling(&rotation, &scale);
m.computeScalingRotation(&scale, &rotation); else
m.computeScalingRotation(&scale, &rotation);
ImGui::SameLine(); ImGui::SameLine();
add_matrix("Rotation component", Transform3d(rotation), 3); add_matrix("Rotation component", Transform3d(rotation), 3);
ImGui::SameLine(); ImGui::SameLine();
add_matrix("Scale component", Transform3d(scale), 3); add_matrix("Scale component", Transform3d(scale), 3);
}
else {
const Geometry::TransformationSVD svd(m);
ImGui::SameLine();
add_matrix("U", Transform3d(svd.u), 3);
ImGui::SameLine();
add_matrix("S", Transform3d(svd.s), 3);
ImGui::SameLine();
add_matrix("V", Transform3d(svd.v), 3);
ImGui::Dummy(ImVec2(0.0f, 0.0f));
float spacing = 0.0f;
if (svd.rotation) {
ImGui::SameLine(0.0f, spacing);
imgui.text_colored(ImGuiWrapper::COL_ORANGE_LIGHT, svd.rotation_90_degrees ? "Rotation 90 degs" : "Rotation");
spacing = 10.0f;
}
if (svd.scale) {
ImGui::SameLine(0.0f, spacing);
imgui.text_colored(ImGuiWrapper::COL_ORANGE_LIGHT, svd.anisotropic_scale ? "Anisotropic scale" : "Isotropic scale");
spacing = 10.0f;
}
if (svd.mirror) {
ImGui::SameLine(0.0f, spacing);
imgui.text_colored(ImGuiWrapper::COL_ORANGE_LIGHT, "Mirror");
spacing = 10.0f;
}
if (svd.skew) {
ImGui::SameLine(0.0f, spacing);
imgui.text_colored(ImGuiWrapper::COL_ORANGE_LIGHT, "Skew");
}
}
} }
}; };