code: private double getDensity(Atom[] ca1subset, Atom[] ca2subset ) throws StructureException{
  
  		Atom centroid1 =  Calc.getCentroid(ca1subset);
  		Atom centroid2 = Calc.getCentroid(ca2subset);
  
  		// get Average distance to centroid ...
  
  		double d1 = 0;
  		double d2 = 0;
  
  		for ( int i = 0 ; i < ca1subset.length;i++){
  			double dd1 = Calc.getDistance(centroid1, ca1subset[i]);
  			double dd2 = Calc.getDistance(centroid2, ca2subset[i]);
  
  			d1 += dd1;
  			d2 += dd2;
  
  		}
  
  		double avd1 = d1 / ca1subset.length;
  		double avd2 = d2 / ca2subset.length;
  
  		return Math.min(avd1,avd2);
  	}
docs: this is probably useless
  
  @param ca1subset
  @param ca2subset
  @return a double
  @throws StructureException