From 1e830d29506379f3a6f6c33cb1548ad2e8e93774 Mon Sep 17 00:00:00 2001 From: Antti Soininen <soininen@ill.fr> Date: Thu, 28 Mar 2019 10:54:38 +0100 Subject: [PATCH] Code beautification. Re #25373 --- Framework/Geometry/inc/MantidGeometry/Objects/CSGObject.h | 4 ++-- Framework/Geometry/src/Rendering/RenderingHelpers.cpp | 5 +++-- Framework/Kernel/inc/MantidKernel/V3D.h | 1 - Framework/Kernel/src/Quat.cpp | 7 +------ qt/widgets/instrumentview/src/PanelsSurface.cpp | 2 +- 5 files changed, 7 insertions(+), 12 deletions(-) diff --git a/Framework/Geometry/inc/MantidGeometry/Objects/CSGObject.h b/Framework/Geometry/inc/MantidGeometry/Objects/CSGObject.h index f9ef3db4d19..b902862920d 100644 --- a/Framework/Geometry/inc/MantidGeometry/Objects/CSGObject.h +++ b/Framework/Geometry/inc/MantidGeometry/Objects/CSGObject.h @@ -137,10 +137,10 @@ public: double solidAngle(const Kernel::V3D &observer, const Kernel::V3D &scaleFactor) const override; // solid angle via triangulation - double triangulatedSolidAngle(const Kernel::V3D &observer) const ; + double triangulatedSolidAngle(const Kernel::V3D &observer) const; // Solid angle via triangulation with scaling factor for object size double triangulatedSolidAngle(const Kernel::V3D &observer, - const Kernel::V3D &scaleFactor) const ; + const Kernel::V3D &scaleFactor) const; // solid angle via ray tracing double rayTraceSolidAngle(const Kernel::V3D &observer) const; diff --git a/Framework/Geometry/src/Rendering/RenderingHelpers.cpp b/Framework/Geometry/src/Rendering/RenderingHelpers.cpp index 98246a5f632..5f88254d430 100644 --- a/Framework/Geometry/src/Rendering/RenderingHelpers.cpp +++ b/Framework/Geometry/src/Rendering/RenderingHelpers.cpp @@ -178,8 +178,9 @@ void renderCuboid(const detail::ShapeInfo &shapeInfo) { // first face glBegin(GL_QUADS); for (auto &row : faceindex) { - const auto normal = normalize((vertex[row[0]] - vertex[row[1]]) - .cross_prod((vertex[row[0]] - vertex[row[2]]))); + const auto normal = + normalize((vertex[row[0]] - vertex[row[1]]) + .cross_prod((vertex[row[0]] - vertex[row[2]]))); glNormal3d(normal[0], normal[1], normal[2]); for (const int ij : row) { if (ij == 0) diff --git a/Framework/Kernel/inc/MantidKernel/V3D.h b/Framework/Kernel/inc/MantidKernel/V3D.h index 3186ed9bf74..df911abce24 100644 --- a/Framework/Kernel/inc/MantidKernel/V3D.h +++ b/Framework/Kernel/inc/MantidKernel/V3D.h @@ -359,7 +359,6 @@ private: MANTID_KERNEL_DLL std::ostream &operator<<(std::ostream &, const V3D &); MANTID_KERNEL_DLL std::istream &operator>>(std::istream &, V3D &); - /** Normalizes a V3D. * @param v a vector to normalize. * @return a vector with norm 1 parallel to v diff --git a/Framework/Kernel/src/Quat.cpp b/Framework/Kernel/src/Quat.cpp index ce7213489e9..4a3b29423a6 100644 --- a/Framework/Kernel/src/Quat.cpp +++ b/Framework/Kernel/src/Quat.cpp @@ -36,12 +36,7 @@ Quat::Quat() : w(1), a(0), b(0), c(0) {} * @param des :: the destination position */ Quat::Quat(const V3D &src, const V3D &des) { - const V3D sum = src + des; - const double l = sum.norm(); - if (l == 0.) { - throw std::runtime_error("Quat: the source and destination vectors cancel each other out."); - } - const V3D v = sum / l; + const V3D v = Kernel::normalize(src + des); const V3D cross = v.cross_prod(des); diff --git a/qt/widgets/instrumentview/src/PanelsSurface.cpp b/qt/widgets/instrumentview/src/PanelsSurface.cpp index adcd683bd1a..316332590c8 100644 --- a/qt/widgets/instrumentview/src/PanelsSurface.cpp +++ b/qt/widgets/instrumentview/src/PanelsSurface.cpp @@ -129,7 +129,7 @@ bool isBankFlat(const ComponentInfo &componentInfo, size_t bankIndex, for (auto tube : tubes) { const auto &children = componentInfo.children(tube); const auto vector = normalize(componentInfo.position(children[0]) - - componentInfo.position(children[1])); + componentInfo.position(children[1])); if (fabs(vector.scalar_prod(normal)) > Mantid::Kernel::Tolerance) { g_log.warning() << "Assembly " << componentInfo.name(bankIndex) << " isn't flat.\n"; -- GitLab