calculateRepulsionForce method

Vector2 calculateRepulsionForce(
  1. Node other, {
  2. required double k,
})

Coulomb's law calculates the repulsive force

Implementation

Vector2 calculateRepulsionForce(Node other, {required double k}) {
  final distance = position.distanceTo(other.position);
  final direction = (position - other.position).normalized();
  return direction * k * k / distance;
}