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 energyyou will need an objectsmassand themagnitute of its velocity, then calculatekinetic energy = 0.5 * mass * (magnitute of velocity)**2.For potential energy, you will need the objects
mass, the magnitute ofgravity(the contstant downwards acceleration) of your space, and the objectsheightrelative to an arbitrary (up to your choice) horizontal zero level. Then calculatepotential 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
kgformass, meters per secondm/sfor magnitudes ofvelocity, meters per second squaredm/(s**2)forgravityand meters (m) forheight. Then the resulting energies are in both JoulesJ = kg*(m* *2)/(s**2).