Browse Source

Fix dqs not checking if quaternions are on the same hemisphere (#2390)

Co-authored-by: Alec Jacobson <[email protected]>
Peizhuo Li 7 months ago
parent
commit
40e7900ccb
1 changed files with 5 additions and 2 deletions
  1. 5 2
      include/igl/dqs.cpp

+ 5 - 2
include/igl/dqs.cpp

@@ -49,8 +49,11 @@ IGL_INLINE void igl::dqs(
     // Loop over handles
     for(int c = 0;c<W.cols();c++)
     {
-      b0.coeffs() += W(i,c) * vQ[c].coeffs();
-      be.coeffs() += W(i,c) * vD[c].coeffs();
+      auto w = W(i,c);
+      if (b0.coeffs().dot(vQ[c].coeffs()) < 0)
+        w = -w;
+      b0.coeffs() += w * vQ[c].coeffs();
+      be.coeffs() += w * vD[c].coeffs();
     }
     Q ce = be;
     ce.coeffs() /= b0.norm();