Add the updateAll function add the Barnes-Hut threshold parameter
This commit is contained in:
parent
4354d167ed
commit
ed6a0c5bc1
2 changed files with 18 additions and 3 deletions
13
src/Lib.hs
13
src/Lib.hs
|
@ -28,6 +28,7 @@ module Lib (
|
|||
acceleration,
|
||||
-- * Simulation
|
||||
update,
|
||||
updateAll,
|
||||
-- * Examples
|
||||
au, sun, earth, moon, mercury, venus, mars
|
||||
) where
|
||||
|
@ -246,6 +247,18 @@ update dt theta tree (Body name r m pos speed) =
|
|||
newpos = pos + dt *^ P newspeed
|
||||
|
||||
|
||||
-- | Update all Bodies with a time step dt and a Barnes-Hut threshold
|
||||
-- theta
|
||||
updateAll :: Double -- ^ The time step
|
||||
-> Double -- ^ The Barnes-Hut threshold theta
|
||||
-> [Body] -- ^ A list of Bodies
|
||||
-> [Body] -- ^ The updated list of Bodies
|
||||
updateAll dt theta bs =
|
||||
map (update dt theta tree) bs
|
||||
where tree = buildTree bs
|
||||
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
-- EXAMPLES
|
||||
--------------------------------------------------------------------------------
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue