Calculating distance and force between charged particles