Log in to vote

How do you calculate the max hight of a particle from a particle emmiter with drag?

Asked by
esepek 103
14 days ago

Since Particles are basically just 2d objects they dont really have a position in 3d space that you could get (at least thats what I know, correct me if I am wrong). I am trying to calculate the maximum hight of a particle just from the predefined values that are given. These are Drag,the Time and the Velocity when the particle starts.With just time and Velocity its very easy (V*t) but I dont know how to include drag into that. I have already looked into the physics of a Vertical throw but from what I know Drag is based on the Velocity wich makes it really hard for me. Now I need a calculation with wich I can calculate wich hight/position the particle will have to a given time.
Thank you for your help, if there is questions to my problem make sure to write a comment below, so I see them.


It shouldn't be too hard to derive an equation manipulating one of the four equations of motion and equating it to force. radiant_Light203 774 — 14d
The problem is that the acceleration (in this case its a negative acceleration) changes over time. So lets say the thing has speed 100 and drag 1 so after 1 second the speed is 50, after 2 seconds it 25,after 3seconds its 12.5. So its based on the last speed wich is based on the last speed wich is based on the starting speed at t= 0. I dont know how to form an equation based on that. esepek 103 — 14d

1 answer

Log in to vote
Answered by
Speedmask 197
14 days ago
Edited 13 days 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.

function integral(func, start, stop, delta)
    local delta = delta or 1e-4
    local int = 0
    for x = start, stop, delta do
        int = int + func(x) * delta
    return int

local INITIAL = 5
local DRAG = 1
function velocity(time)
    return INITIAL * 0.5 ^ (time * DRAG)

local END_TIME = 1
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.

Hey there, thank youery much for your solution. What you sent me there seems like it should be right. I havent had Integrals in school yet, so therefore I had no clue about it. Since its already preatty late in my country I am gonna get some sleep now and test it out tomorrow. So please give me some time to accept the answer.Thank you very much for your time and thoughts you put into this,esepek. esepek 103 — 14d
hi, no problem. if you do not want to go into the details of integrals, simply put, it is the area between a graph and the axis, starting from the bottom number to the top number. if you ever get the integral of something's velocity, it amounts to the total distance covered which is useful for particles like these. let me know if you need help putting it into code. Speedmask 197 — 14d
Youp I dont know how to calculate an integral in lua, I searched in the internet for it, but they all seem to use a C++ library... It would be great if you could show me how I could use integrals in my script, my discord is Esepek#9540 , if you want to contact me there. esepek 103 — 13d

Answer this question