-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gravity.lua
32 lines (27 loc) · 844 Bytes
/
Gravity.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
local Math = require "Math"
local Gravity = {}
-- PE = mgh
---@param mass number
---@param height number
---@return number potentialEnergy J
function Gravity:potentialEnergy(mass, height)
local potentialEnergy = mass * Math.GRAVITY * height
return potentialEnergy
end
-- m = j/(gh)
---@param potentialEnergy number
---@param height number
---@return number potentialMass kg
function Gravity:PotentialMass(potentialEnergy, height)
local potentialMass = potentialEnergy / (Math.GRAVITY * height)
return potentialMass
end
-- h = j / (mg)
---@param potentialEnergy number
---@param potentialMass number
---@return number potentialHeight m
function Gravity:potentialHeight(potentialEnergy, potentialMass)
local potentialHeight = potentialEnergy / (potentialMass * Math.GRAVITY)
return potentialHeight
end
return Gravity