increasing performances
explicit for loop instead of sum in Node.get_force
This commit is contained in:
parent
e93cae162b
commit
8b2b2a9c34
1 changed files with 7 additions and 1 deletions
|
@ -117,7 +117,13 @@ class Node:
|
|||
if self.is_external or self.width*self.width / dist_squared < THETA_SQUARED:
|
||||
return newton_law(self.mass, star.mass, self.center - star.pos)
|
||||
else:
|
||||
return sum((child.get_force(star) for child in self.children), Vec3.zero())
|
||||
acc = Vec3.zero()
|
||||
for child in self.children:
|
||||
acc += child.get_force(star)
|
||||
return acc
|
||||
|
||||
#return sum((child.get_force(star) for child in self.children), Vec3.zero()) #slower
|
||||
|
||||
|
||||
|
||||
"""Init simulation"""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue