My physics doesn't add up.. but why?

Hey guys,

I was just doing some testing on Box2D (2.1.0) for a game I'm trying to put together.

The testing is pretty simple. I want my game character to jump to a certain height.
So, I create a static floor and a dynamic object (of 1 by 1, density 50, friction 0).

Using my somewhat rusty physics memory, I came to:
E = m . g . h
E = 0.5 . m . v^2
thus
v = sqrt( g . h . 2.0 ) // `v` would be the velocity after a fall from `h` height

Great! Or so I thought. Now just set the take-off velocity to v.
But somehow, this doesn't add up.

What I notice are 2 things.
- I always fall a little short
- I fall a lot short with high gravity (like my max speed is capped?!)

The higher I set the gravity, the more it falls short. Perhaps I'm missing a compensation for something in my formula? What am I doing wrong here?

Also, when gravity is at 100, I can't "jump" over 73 meters, and with gravity at 1000, I can't jump over 8.2 meters. Is there a cap on speed?

I've tried using SetLinearVelocity and ApplyImpulse with v * m (which sets the velocity anyway)
Both come to exactly the same result.

I can post some sample code if that helps.. but it's all pretty straight forward.

I measured the maximum height I found for every object (timestep of 1/60). I realise that actual height can of course be different if I decrease the timestep, but it's too far off for that to be the problem, I think.

Below a list of maximum measured heights, with between parenthesis the second highest height.
-----------------------------------

Gravity: 10.00
Jump height set to: 1.00 but max measured height was: 0.9779 (0.9774)
Jump height set to: 10.00 but max measured height was: 9.8973 (9.8969)
Jump height set to: 100.00 but max measured height was: 99.6424 (99.6415)

Gravity: 100.00
Jump height set to: 1.00 but max measured height was: 0.9006 (0.8871)
Jump height set to: 10.00 but max measured height was: 9.6442 (9.6396)
Jump height set to: 100.00 but max measured height was: 73.0150 (73.0150)

Gravity: 1000.00
Jump height set to: 1.00 but max measured height was: 0.6724 (0.5844)
Jump height set to: 10.00 but max measured height was: 8.2372 (8.1816)
Jump height set to: 100.00 but max measured height was: 8.2372 (8.1816)

-----------------------------------

So to summerise:
Box2D version 2.1.0 (comes with Cocos2d 0.99.0rc1)
Applying impulse or velocity to object doesn't behave as expected. Gravity has some effect that I cannot explain.

Thanks in advance for any help!
Box2D does a linear approximation of high order equations by using Euler iterations. You should choose a target timestep size and stick with it, and tune from there.

Original thread: https://box2d.org/forum/viewtopic.php?t=4581