implemented barnes-hut algorithm