cyclone-physics icon indicating copy to clipboard operation
cyclone-physics copied to clipboard

Confusing acceleration calculation

Open SomeAndrian opened this issue 12 years ago • 6 comments

// Calculate the resulting acceleration and therefore the force Vector3 accel = (target - position) * (1.0f / duration*duration) - particle->getVelocity() * duration;

Shouldn't that be:

// Calculate the resulting acceleration and therefore the force Vector3 accel = (target - position) * (1.0f / duration*duration) - particle->getVelocity() * (1.0f / duration);

SomeAndrian avatar Jul 14 '12 17:07 SomeAndrian

in pfgen.cpp

ParticleFakeSpring::updateForce

SomeAndrian avatar Jul 14 '12 17:07 SomeAndrian

I'd love some confirmation, please

SomeAndrian avatar Jul 20 '12 00:07 SomeAndrian

It seems to me that @SomeAndrian s right. If one check the SI units on that equation, there is mismatch. As you seem to be summing m/s² with m. Adding the correction @SomeAndrian proposed will make everything correct.

Also, on the book, Eq. 6.5 (from which that code was drawn) has the same error. Dividing dp/dt by t will correct it.

LucasCampos avatar Feb 28 '13 11:02 LucasCampos

Looks like there's one more miscalculation on that code.

(1.0f / duration*duration) 

will be calculated as

(1.0f / duration)*duration

not as

1.0f / (duration*duration)

LucasCampos avatar Feb 28 '13 11:02 LucasCampos

Thank you

SomeAndrian avatar Feb 28 '13 12:02 SomeAndrian

Regarding the same issue, formula 6.5 stands for

$\ddot{p}=(p_t-p_0)\frac{1}{t^2}-\dot{p_0}$

As @LucasCampos says, there is a t missing in the formula, so it should be

$\ddot{p}=(p_t-p_0)\frac{1}{t^2}-\frac{\dot{p_0}}{t}$

But, if this formula comes, as I suspect, from uniform acceleration motion, since where are guessing that during all the frame we are applying the same acceleration to get the particle exactly to the position we want, $p_t=p_0 +\dot{p_0}t+\frac{1}{2}\ddot{p}t^2$

Are we missing the 2 factor as well in the final formula, getting the following formula as the corrected 6.5? $\ddot{p}=\frac{2}{t^2}(p_t-p_0)-\frac{2}{t}\dot{p_0}$

Maesla avatar May 14 '24 15:05 Maesla