Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  Extracting acting forces on particle
#5
(23-06-2023, 06:26 AM)KnotANumber Wrote: I guess I also can know the direction of the force that's being applied to the attachment, because I can subtract the position of a particle to the position of the next particle (like this other user did in their first solution).

It's not possible to know the *exact* direction of the force, because there's no single direction. Every iteration, constraints move particles in the direction of their jacobian (aka, constraint gradient) which changes with every iteration - since each particle is usually affected by more than 1 constraint and each constraint pushes/pulls in a different direction, so to speak. There may be more than 1 iteration per physics step and more than 1 physics step per frame, so by the end of the frame the particle has moved in a multitude of directions. See: http://obi.virtualmethodstudio.com/manua...gence.html

You can use the constraint gradient at the end of the frame as a rough approximation of the net direction (like TimmyVonMoerkel did above), but depending on your use case this may not be accurate enough.

(23-06-2023, 06:26 AM)KnotANumber Wrote: All that would be left would be to do would be `direction.normalized * batch.lambas[constraintIndex] / (deltaTime * deltaTime)`?

Correct.

(23-06-2023, 06:26 AM)KnotANumber Wrote: I don't understand how to get the specific batch and the constraint index of a specific particle.

You can't, for obvious reasons: each particle is not affected by a single constraint, but by many of them and each constraint is in a different batch to avoid race conditions. So the engine -most physics engines, in fact- is optimized for the exact opposite access pattern: for each constraint, list all particles/bodies affected by it.

If you want to get all constraints that affect a single particle, the only way is to iterate trough all constraints in all batches and pick those that reference your particle. This isn't very efficient but luckily, it's usually not needed.

This page in the manual goes into details about how constraints and particles relate to each other, it might help:
http://obi.virtualmethodstudio.com/manua...aints.html

kind regards,
Reply


Messages In This Thread
RE: Extracting acting forces on particle - by josemendez - 23-06-2023, 03:40 PM