Remove unnecessary calls to normalize

This commit is contained in:
Dimitri Lozeve 2017-11-21 15:29:39 +00:00
parent 93514d456e
commit 30be811103

View file

@ -232,7 +232,7 @@ buildTree bs = foldr insertBody (Empty r) bs
-- | Field created by a body on a certain position -- | Field created by a body on a certain position
field :: Body -> Point V3 Double -> V3 Double field :: Body -> Point V3 Double -> V3 Double
field body pos = field body pos =
unP $ (gravity * m / r**2) *^ normalize vec unP $ (gravity * m / r**3) *^ vec
where m = _bodyMass body where m = _bodyMass body
vec = _bodyPosition body - pos vec = _bodyPosition body - pos
r = norm vec r = norm vec
@ -249,7 +249,7 @@ acceleration theta tree body = case tree of
vec = _regionCenterOfMass r - _bodyPosition body vec = _regionCenterOfMass r - _bodyPosition body
d = norm vec in d = norm vec in
if s/d < theta then if s/d < theta then
unP $ (gravity * _regionMass r / d**2) *^ normalize vec unP $ (gravity * _regionMass r / d**3) *^ vec
else else
acceleration theta ned body + acceleration theta ned body +
acceleration theta nwd body + acceleration theta nwd body +