code: public static final int dimensionality(SpatialComparable o1, SpatialComparable o2) {
      final int dim1 = o1.getDimensionality(), dim2 = o2.getDimensionality();
      if(dim1 != dim2) {
        throw new IllegalArgumentException("Objects do not have the same dimensionality.");
      }
      return dim1;
    }
docs: Get the common dimensionality of the two objects. Throw an
  {@link IllegalArgumentException} otherwise.
  
  @param o1 First vector / MBR
  @param o2 Second vector / MBR
  @return Common dimensionality
  @throws IllegalArgumentException when dimensionalities are not the same.