diff --git a/src/mol-math/linear-algebra/3d/vec3.ts b/src/mol-math/linear-algebra/3d/vec3.ts
index d39cbba843d79881eea6e8151cee67217e1cd040..74531f85a3088319d421f26b7fed5c113632e729 100644
--- a/src/mol-math/linear-algebra/3d/vec3.ts
+++ b/src/mol-math/linear-algebra/3d/vec3.ts
@@ -48,6 +48,10 @@ namespace Vec3 {
         return out;
     }
 
+    export function hasUndetermined(a: Vec3): boolean {
+        return isFinite(a[0]) && isFinite(a[1]) && isFinite(a[2]);
+    }
+
     export function hasNaN(a: Vec3) {
         return isNaN(a[0]) || isNaN(a[1]) || isNaN(a[2]);
     }
@@ -636,4 +640,4 @@ namespace Vec3 {
     export const negUnitZ: ReadonlyVec3 = create(0, 0, -1);
 }
 
-export { Vec3 };
\ No newline at end of file
+export { Vec3 };
diff --git a/src/mol-math/linear-algebra/matrix/principal-axes.ts b/src/mol-math/linear-algebra/matrix/principal-axes.ts
index 90091e1e123a20a112fb2439edf4ef1f9982e163..241c11058f556b95745a405fe46ad60265915f3a 100644
--- a/src/mol-math/linear-algebra/matrix/principal-axes.ts
+++ b/src/mol-math/linear-algebra/matrix/principal-axes.ts
@@ -2,6 +2,7 @@
  * Copyright (c) 2018-2022 mol* contributors, licensed under MIT, See LICENSE file for more info.
  *
  * @author Alexander Rose <alexander.rose@weirdbyte.de>
+ * @author Gianluca Tomasello <giagitom@gmail.com>
  */
 
 import { Matrix } from './matrix';
@@ -123,12 +124,17 @@ namespace PrincipalAxes {
         const dirB = Vec3.setMagnitude(Vec3(), a.dirB, (d2a + d2b) / 2);
         const dirC = Vec3.setMagnitude(Vec3(), a.dirC, (d3a + d3b) / 2);
 
+        const okDirA = Vec3.hasUndetermined(dirA);
+        const okDirB = Vec3.hasUndetermined(dirB);
+        const okDirC = Vec3.hasUndetermined(dirC);
+
         const origin = Vec3();
         const addCornerHelper = function (d1: number, d2: number, d3: number) {
             Vec3.copy(tmpBoxVec, center);
-            Vec3.scaleAndAdd(tmpBoxVec, tmpBoxVec, a.dirA, d1);
-            Vec3.scaleAndAdd(tmpBoxVec, tmpBoxVec, a.dirB, d2);
-            Vec3.scaleAndAdd(tmpBoxVec, tmpBoxVec, a.dirC, d3);
+
+            if (okDirA) Vec3.scaleAndAdd(tmpBoxVec, tmpBoxVec, a.dirA, d1);
+            if (okDirB) Vec3.scaleAndAdd(tmpBoxVec, tmpBoxVec, a.dirB, d2);
+            if (okDirC) Vec3.scaleAndAdd(tmpBoxVec, tmpBoxVec, a.dirC, d3);
             Vec3.add(origin, origin, tmpBoxVec);
         };
         addCornerHelper(d1a, d2a, d3a);