diff options
author | Joris Guyonvarch | 2015-03-07 15:12:02 +0100 |
---|---|---|
committer | Joris Guyonvarch | 2015-03-07 15:12:02 +0100 |
commit | 17a58e0c4c67f27d87635bf1b2ca50fb11795ad3 (patch) | |
tree | 8de99cdf0b4021ca6db6920537e7d0fa250e90bc /src/Physics.elm | |
parent | 336816d2e8ab4afff1562123dfde61bf3a68e61c (diff) |
Organizing source code with subdirectories
Diffstat (limited to 'src/Physics.elm')
-rw-r--r-- | src/Physics.elm | 42 |
1 files changed, 0 insertions, 42 deletions
diff --git a/src/Physics.elm b/src/Physics.elm deleted file mode 100644 index c68ab58..0000000 --- a/src/Physics.elm +++ /dev/null @@ -1,42 +0,0 @@ -module Physics where - -import Vec2 (..) - -getNewPosAndSpeed : Float -> Vec2 -> (Float -> Float) -> (Vec2, Vec2) -> (Vec2, Vec2) -getNewPosAndSpeed dt dir computeSpeed (pos, speed) = - let move = getMove (computeSpeed dt) dir - acc = getAcc move speed - newPos = getNewPos dt acc speed pos - newSpeed = getNewSpeed dt acc speed - in ( newPos - , newSpeed - ) - -getMove : Float -> Vec2 -> Vec2 -getMove speed dir = - if (isNull dir) - then {x = 0, y = 0} - else - let angle = atan2 dir.y dir.x - in { x = speed * cos angle - , y = speed * sin angle - } - -getWaveMove : Float -> Vec2 -> Float -> Float -> Vec2 -getWaveMove speed dir amplitude period = - let move = getMove speed dir - perpendMove = - getMove - (amplitude * (sin ((norm move) / period))) - (clockwiseRotate90 move) - in move `add` perpendMove - -getAcc : Vec2 -> Vec2 -> Vec2 -getAcc move speed = (move `div` 300) `sub` (speed `div` 300) - -getNewPos : Float -> Vec2 -> Vec2 -> Vec2 -> Vec2 -getNewPos dt acc speed pos = - ((dt^2 / 2) `mul` acc) `add` ((dt `mul` speed) `add` pos) - -getNewSpeed : Float -> Vec2 -> Vec2 -> Vec2 -getNewSpeed dt acc speed = add (mul dt acc) speed |