From 31e52cc90748f2a2b80232682ec2214fb71f140d Mon Sep 17 00:00:00 2001
From: Florent Lamiraux <florent@laas.fr>
Date: Thu, 6 Dec 2018 16:14:29 +0100
Subject: [PATCH] [OBB] Simplify expression in
 obbDisjointAndLowerBoundDistance.

---
 src/BV/OBB.cpp | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/src/BV/OBB.cpp b/src/BV/OBB.cpp
index b462aaff..8e0fdcc3 100644
--- a/src/BV/OBB.cpp
+++ b/src/BV/OBB.cpp
@@ -314,18 +314,13 @@ bool obbDisjointAndLowerBoundDistance (const Matrix3f& B, const Vec3f& T,
 
   // Corner of b axis aligned bounding box the closest to the origin
   Vec3f AABB_corner (T.cwiseAbs () - Bf * b);
-  Vec3f diff3 (AABB_corner - a);
-  diff3 = diff3.cwiseMax (0);
-  //for (Vec3f::Index i=0; i<3; ++i) diff3 [i] = std::max (0, diff3 [i]);
-  squaredLowerBoundDistance = diff3.squaredNorm ();
+  squaredLowerBoundDistance = (AABB_corner - a).cwiseMax (0).squaredNorm ();
   if (squaredLowerBoundDistance > breakDistance2)
     return true;
 
   AABB_corner = (B.transpose () * T).cwiseAbs ()  - Bf.transpose () * a;
-  // diff3 = | B^T T| - b - Bf^T a
-  diff3 = AABB_corner - b;
-  diff3 = diff3.cwiseMax (0);
-  squaredLowerBoundDistance = diff3.squaredNorm ();
+  // | B^T T| - b - Bf^T a
+  squaredLowerBoundDistance = (AABB_corner - b).cwiseMax (0).squaredNorm ();
 
   if (squaredLowerBoundDistance > breakDistance2)
     return true;
-- 
GitLab