diff --git a/Polyhedron/demo/Polyhedron/Plugins/PCA/Affine_transform_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/PCA/Affine_transform_plugin.cpp index 1a0a9e34f35e..d651bdcd61b6 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/PCA/Affine_transform_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/PCA/Affine_transform_plugin.cpp @@ -614,12 +614,20 @@ endPointSet(const QMatrix4x4& transform_matrix) Point_set* new_ps = new_item->point_set(); CGAL::qglviewer::Vec c = aff_transformed_item->center(); + QMatrix3x3 normal_matrix = transform_matrix.normalMatrix(); + for(Point_set::Index idx : *new_ps) { QVector3D vec = transform_matrix.map(QVector3D(new_ps->point(idx).x() - c.x, new_ps->point(idx).y() - c.y, new_ps->point(idx).z() - c.z)); new_ps->point(idx) = Kernel::Point_3(vec.x(), vec.y(), vec.z()); + if (new_ps->has_normal_map()) { + QVector3D n(new_ps->normal(idx).x(), new_ps->normal(idx).y(), new_ps->normal(idx).z()); + new_ps->normal(idx) = Kernel::Vector_3(normal_matrix(0, 0) * n[0] + normal_matrix(0, 1) * n[1] + normal_matrix(0, 2) * n[2], + normal_matrix(1, 0) * n[0] + normal_matrix(1, 1) * n[1] + normal_matrix(1, 2) * n[2], + normal_matrix(2, 0) * n[0] + normal_matrix(2, 1) * n[1] + normal_matrix(2, 2) * n[2]); + } } new_item->setName(aff_transformed_item->name());