Answered by
4 years ago Edited 4 years ago
hey, correct me if my math is wrong because I have not done integrals in a while :)
your velocity at a particular time can be given as v0 * 0.5^(td), with v0 as the starting velocity and d as the drag value. this is because according to the documentation on particle emitters:
Determines the rate at which particles will lose half their speed through exponential decay
therefore you can get the integral of the velocity from zero to whatever amount of time you want to get the distance covered, which I think is what you want.
EDIT: now that we have worked out the code, I am pasting this script down here in case it helps someone.
01 | function integral(func, start, stop, delta) |
02 | local delta = delta or 1 e- 4 |
04 | for x = start, stop, delta do |
05 | int = int + func(x) * delta |
12 | function velocity(time) |
13 | return INITIAL * 0.5 ^ (time * DRAG) |
17 | print (integral(velocity, 0 , END_TIME, 0.01 )) |
your delta value will affect the measurements' accuracy, but it will also require more calculations per seconds. you can toy around with it and find a suitable delta value.