MADEAPPS / newton-dynamics

Newton Dynamics is an integrated solution for real time simulation of physics environments.
http://www.newtondynamics.com
Other
951 stars 182 forks source link

60 fps assumption #265

Closed TrevorCash closed 2 years ago

TrevorCash commented 2 years ago

Hi Julio,

Im not sure how the math works here, but will running the sim at a different fps have different damping results because of the 60fps assumption?

https://github.com/MADEAPPS/newton-dynamics/blob/0b94ab3098c1ca2e61084daf9261452041d1d8b3/newton-4.00/sdk/dNewton/ndBodyDynamic.cpp#L269-L270

JulioJerez commented 2 years ago

no it wouldn't. teh code that follows

    ndFloat32 tau = ndFloat32(60.0f) * timestep;
    // recalculate damping to match the time independent drag
    m_cachedDampCoef.m_x = ndPow(ndFloat32(1.0f) - m_dampCoef.m_x, tau);

calculate the equivalent attenuation for any multiple of teh attenuation at 60 hertz

let us say that the time step in 1/60 the tau will be ndFloat32 tau = ndFloat32(60.0f) / 60 = 1.0;

therefore m_cachedDampCoef.m_x = ndPow(ndFloat32(1.0f) - m_dampCoef.m_x, 1) = 1 - m_cachedDampCoef.m_x;

let use now say time step = 0.5 / 60.0 tau will be ndFloat32 tau = ndFloat32(60.0f) * 0.5/ 60 = 0.5f;

therefore m_cachedDampCoef.m_x = ndPow(ndFloat32(1.0f) - m_dampCoef.m_x, 0.5) = (1 - m_cachedDampCoef.m_x) ^ 0.5; and so on, thsi works for fraction or integer multiple of the same fps.

it is eassy to derive from power series.