Skip to content

Commit 80a3eaa

Browse files
committed
Now catching empty arrays in getCentroid
1 parent fc2d368 commit 80a3eaa

File tree

1 file changed

+4
-0
lines changed
  • biojava-structure/src/main/java/org/biojava/nbio/structure

1 file changed

+4
-0
lines changed

biojava-structure/src/main/java/org/biojava/nbio/structure/Calc.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -777,6 +777,10 @@ public static final void shift(Group group, Atom a) {
777777
* @return an Atom representing the Centroid of the set of atoms
778778
*/
779779
public static final Atom getCentroid(Atom[] atomSet) {
780+
781+
// if we don't catch this case, the centroid returned is (NaN,NaN,NaN), which can cause lots of problems down the line
782+
if (atomSet.length==0)
783+
throw new IllegalArgumentException("Atom array has length 0, can't calculate centroid!");
780784

781785
double[] coords = new double[3];
782786

0 commit comments

Comments
 (0)