I want to calculate the Kinetic energy and potential energy of the ball I just Spawned inside a Pymunk space.
I wanted to replicate this.
Where the values change in real-time along with the graph. from what I saw in the documentation these are the things we can get from the body:
Kinetic energy
velocity
mass
but some of them are in vec2d object idk how that works.
To determine kinetic energy
you will need an objects mass
and the magnitute of its velocity
, then calculate
kinetic energy = 0.5 * mass * (magnitute of velocity)**2
.
For potential energy, you will need the objects mass
, the magnitute of gravity
(the contstant downwards acceleration) of your space, and the objects height
relative to an arbitrary (up to your choice) horizontal zero level. Then calculate
potential energy = mass * magnitude of gravity * relative height
.
To keep the measurings consistent, you must use the same units of measurements in each calculation. Sticking with SI unit is probably the wisest, so kilograms kg
for mass
, meters per second m/s
for magnitudes of velocity
, meters per second squared m/(s**2)
for gravity
and meters (m) for height
. Then the resulting energies are in both Joules J = kg*(m* *2)/(s**2)
.