Open adamgreig opened 8 years ago
This is intentional, because velocity measured per step can often be more convenient than per second in some cases when time is discrete. I understand this may be a little confusing for those expecting this to match the usual definition. I should definitely update the documentation that makes note of this.
But I'm not sure that this should be changed in the code at this stage as it might mean lots of extra conversions, or a second velocity value to be stored which would be confusing? So I think it's better at the moment that you convert or calculate your own velocities as suits your application. Also see a similar discussion in #179.
Ok, thanks, that makes sense. It's certainly an easy conversion to make once you know what's going on, but caused me some confusion at first!
It might be nice to also document that the base units for time are milliseconds, so forces are measured in meganewtons, if you want to apply real-world units to things.
In
Body.update
, the body "velocity" is computed, but this is actually a "change in position for this timestep", i.e., has units of "metres per 1/60 seconds" rather than "metres per second". If you compare to the reference for your Verlet integration scheme, the quantity computed isn't labelledv
for presumably this reason.To be more concrete, you can (I did) run a simple experiment with a falling object in gravity, logging the time, height, and velocity at each step. Then compute the velocity as "dh/dt" between each time step and you'll find the result is much (1/60) smaller than what gets saved as
body.velocity
.This doesn't cause errors in the actual physics because the computations are all as they should be, but the velocity number is wrong if you try to use it for anything else (in my case, computing kinetic energy). It might also affect things like the friction calculations but I haven't looked.
The solution is to bind this as
velocity
in the update function, but setbody.velocity
tovelocity / deltaTime
.