}
@Override
public ForceVector calculateForce(Node node1, Node node2,
float distance) {
ForceVector f = new ForceVector(node2.x() - node1.x(),
node2.y() - node1.y());
float scale = -relativeStrength * optimalDistance * optimalDistance / (distance * distance);
if (Float.isNaN(scale) || Float.isInfinite(scale)) {
scale = -1;
}
f.multiply(scale);
return f;
}