Просмотр исходного кода

Fixed degenerate case (1-point) in PCA (#725)

* Fixed degenerate case (1-point) in PCA - now correctly returns identity matrix

* Changelog
midlik 2 лет назад
Родитель
Сommit
9870cb4082
2 измененных файлов с 3 добавлено и 2 удалено
  1. 1 0
      CHANGELOG.md
  2. 2 2
      src/mol-math/linear-algebra/matrix/principal-axes.ts

+ 1 - 0
CHANGELOG.md

@@ -7,6 +7,7 @@ Note that since we don't clearly distinguish between a public and private interf
 ## [Unreleased]
 
 Fix impostor bond visuals not correctly updating on `sizeFactor` changes
+Fix degenerate case in PCA
 
 ## [v3.31.2] - 2023-02-12
 

+ 2 - 2
src/mol-math/linear-algebra/matrix/principal-axes.ts

@@ -27,7 +27,7 @@ namespace PrincipalAxes {
 
     export function calculateMomentsAxes(positions: NumberArray): Axes3D {
         if (positions.length === 3) {
-            return Axes3D.create(Vec3.fromArray(Vec3(), positions, 0), Vec3.create(1, 0, 0), Vec3.create(0, 1, 0), Vec3.create(0, 1, 0));
+            return Axes3D.create(Vec3.fromArray(Vec3(), positions, 0), Vec3.create(1, 0, 0), Vec3.create(0, 1, 0), Vec3.create(0, 0, 1));
         }
 
         const points = Matrix.fromArray(positions, 3, positions.length / 3);
@@ -143,4 +143,4 @@ namespace PrincipalAxes {
 
         return Axes3D.create(origin, dirA, dirB, dirC);
     }
-}
+}