private ProjectedEnergy projectedEnergy(Relation<V> database, DistanceQuery<V, DoubleDistance> distFunc, ORCLUSCluster c_i, ORCLUSCluster c_j, int i, int j, int dim) {
// union of cluster c_i and c_j
ORCLUSCluster c_ij = union(database, distFunc, c_i, c_j, dim);
V factory = DatabaseUtil.assumeVectorField(database).getFactory();
DoubleDistance sum = getDistanceFunction().getDistanceFactory().nullDistance();
V c_proj = projection(c_ij, c_ij.centroid, factory);
for(DBID id : c_ij.objectIDs) {
V o = database.get(id);
V o_proj = projection(c_ij, o, factory);
DoubleDistance dist = distFunc.distance(o_proj, c_proj);
sum = sum.plus(dist.times(dist));
}
DoubleDistance projectedEnergy = sum.times(1.0 / c_ij.objectIDs.size());
return new ProjectedEnergy(i, j, c_ij, projectedEnergy);
}