/// free fall acceleration in m/s² const double g = 9.81; /// /// Potential Energy = [mass] * [height] * g /// with [mass] in kg, [height] in m and result in m²kg/s² = Joule double potential(double mass, double height) { return mass * height * g; } double freedPotential(double mass, double hStart, double hEnd) { return potential(mass, hStart) - potential(mass, hEnd); } /// /// Kinetic energy = 0.5 [mass] * [velocity] * [velocity] /// with [mass] in kg and velocity in m/s and result in m²kg/s² = Joule double kinetic(double mass, double velocity) { return mass * velocity * velocity / 2; } double freedKinetic(double mass, double vStart, double vEnd) { return kinetic(mass, vStart) - kinetic(mass, vEnd); } /// /// Amount of freed energy when an object changes its height from [hStart] m to [hEnd] m /// and changes its velocity from [vStart] m/s² to [vEnd] m/s². double freedEnergy(double mass, double hStart, double hEnd, double vStart, double vEnd) { return freedPotential(mass, hStart, hEnd) + freedKinetic(mass, vStart, vEnd); }