cyclone-physics
cyclone-physics copied to clipboard
Confusing acceleration calculation
// 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);
in pfgen.cpp
ParticleFakeSpring::updateForce
I'd love some confirmation, please
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.
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)
Thank you
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}$