Question about @TimeInc in Houdini dynamics.

   3029   7   0
User Avatar
Member
20 posts
Joined: June 2019
Offline
When I'm trying to understand the simulation process of DOP network, and try to write it from scratch in the SOP solver. I find that the calculation order of DOP network is like e.g.

 vector velocity = set(3, 1, 0);
 vector force = set(0,-1,0);
 v@finalvel = velocity + force * @TimeInc; //Add the S velocity to the frame force?
 v@framevel = v@finalvel * @TimeInc ; 


But my question is why can't it be written like this?

vector velocity = set(3, 1, 0);
vector force = set(0,-1,0);
v@finalvel = velocity * @TimeInc + force * @TimeInc;
v@framevel = v@finalvel ;

Why not just multiply velocity by @TimeInc at the beginning and then add the force multiplied by @TimeInc?
Wouldn't that be
 v@framevel = velocity * @TimeInc + force * @TimeInc * @TimeInc
if we followed the first way. So we multiplied force by @TimeInc twice? Isn't it OK to just use the frame velocity add the frame force directly?

Thanks
Edited by ILIAZHAO - June 26, 2022 13:00:51
User Avatar
Member
8532 posts
Joined: July 2007
Offline
it's ultimately up to you how you design your solver

how Houdini solvers work is that v, accel, force are all represented as units per second
so if you want to replicate that and potentially stay compatible it's not helpful to do a oneliner that reduces v to units per timestep since then you would have to divide it by @TimeInc again to get v per second to pass to next tiemstep

the reason you don't want to keep v attribute in unit per timestep is that timestep can vary, @TimeInc doesn't represent frame if substeps are involved whether DOP level or introduced by other microsolvers like GasSubstep DOP etc.

so you may want something like this:
v@v +=  v@force / f@mass * @TimeInc;
v@P +=  v@v * @TimeInc;
v@force = 0;

that way v@v stays in units per second
Edited by tamte - June 26, 2022 15:00:38
Tomas Slancik
FX Supervisor
Method Studios, NY
User Avatar
Member
20 posts
Joined: June 2019
Offline
Thank you Tomas.
Sorry, but I just want to make it clear that according to your code, it won't be the result that should be expected mathematically. Is that right? For example, suppose v= (3, 1, 0), force= (0, -1, 0) should theoretically get (1, 0, 0) after one second, but according to your algorithm, this is not the case.

On the contrary, if we multiply V by @TimeInc at the beginning to get frame based V, and then use frame based force to affect frame based V,like(velocity * @TimeInc + force * @TimeInc) we will get the expected value.
User Avatar
Member
8532 posts
Joined: July 2007
Offline
ILIAZHAO
For example, suppose v= (3, 1, 0), force= (0, -1, 0) should theoretically get (1, 0, 0) after one second, but according to your algorithm, this is not the case.
I'm gonna assume you meant that the result should be (3,0,0)
and that's exactly what you'll get after 1s
if it makes it easier you can assume f@mass=1 and therefore remove it from the equation if you want to start simple or if you only need gravity
Tomas Slancik
FX Supervisor
Method Studios, NY
User Avatar
Member
54 posts
Joined: Sept. 2008
Offline
The unit of velocity is distance/second.
Velocity multiplied by time becomes distance.
The unit of force is the same as that of acceleration.
So acceleration multiplied by second becomes velocity.

If initial velocity is 10 and force(acceleration) is applied for 0.1 seconds:
Final velocity = initial velocity + acceleration * 0.1

Why do you think you should multiply time to the velocity?
Edited by ifree - June 27, 2022 09:11:10
User Avatar
Member
20 posts
Joined: June 2019
Offline
Oh, Sorry. You are right (3, 0, 0) I accidentally typed the wrong number.

And I finally understood my mistake.
The reason why I write (velocity * @TimeInc + force * @TimeInc) is that I regard the force here as a constant velocity rather than an acceleration.
This will cause my solver to produce a uniform motion rather than a quadratic function trajectory. I didn't wrap my mind about this at that time.

Thank you for your help.
User Avatar
Member
20 posts
Joined: June 2019
Offline
@ifree At the beginning, I wanted to multiply the initial velocity by @TimeInc because I thought the initial velocity was based on seconds rather than frames, so I wanted to change that to frame Initial velocity.
User Avatar
Member
20 posts
Joined: June 2019
Offline
@ifree
Thank you for your reply. I confused some concepts before. The initial velocity is constant in every frame or second, unless I want it to affect the position, I need to divide it by 24. I multiplied the initial velocity by @timeinc, which means that I mistakenly took the initial velocity as the initial acceleration, so I thought I would get its value at each frame.
  • Quick Links