Run and export to CSV
This commit is contained in:
parent
cbc770f340
commit
104ec50dcd
3 changed files with 44 additions and 14 deletions
23
app/Main.hs
23
app/Main.hs
|
@ -2,5 +2,26 @@ module Main where
|
|||
|
||||
import Lib
|
||||
|
||||
import Linear.Affine
|
||||
import Linear.V3
|
||||
|
||||
csvFromPoint :: Point V3 Double -> String
|
||||
csvFromPoint (P (V3 x y z)) =
|
||||
show x ++ "," ++ show y ++ "," ++ show z
|
||||
|
||||
csvFromBodies :: [Body] -> [String]
|
||||
csvFromBodies [] = []
|
||||
csvFromBodies (x:xs) =
|
||||
(bodyName x ++ ","
|
||||
++ (show $ bodyMass x) ++ ","
|
||||
++ (csvFromPoint $ bodyPosition x) ++ "\n")
|
||||
:(csvFromBodies xs)
|
||||
|
||||
steps :: Int -> Double -> [Body] -> IO ()
|
||||
steps 0 _ _ = return ()
|
||||
steps n dt bodies = do
|
||||
putStr . concat $ map ((++) (show n ++ ",")) $ csvFromBodies bodies
|
||||
steps (n-1) dt (updateAll dt bodies)
|
||||
|
||||
main :: IO ()
|
||||
main = putStrLn "Hello"
|
||||
main = steps 1000000 10 [sun, earth, moon]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue