1
$\begingroup$

I am referring, as an example, to Blender's particle collision system, where you can set the randomness for particle damping between 0.0 and 1.0. My question now is: how does it exactly work? Yes, there will be a random number between 0.0 and 1.0 but how is it applied to the damping factor? I want to create something similar in Java and therefore I want to fully understand the calculation behind that. Is the random factor the probability p and the calculation something like a gaussian distribution?

$\endgroup$
1
$\begingroup$

I figured it out.

public Vector3f damping(Vector3f vector) 
{
    float random = (float) (this.randomDamp*(Math.random()*2-1));
    float clampedValue = Math.max(0, Math.min(1, (1-damp)+random)); //clamp between 0 and 1
    vector.scale(clampedValue);
    return vector;
}

With a factor of 0.5 and a random factor of 1, the final factor will vary between -0.5 (0) and 1.5 (1)

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.