michael879 100 Report post Posted October 9, 2006 Im writing a physics library and I want it to support both continuous projectile paths and segmented paths (just takes a function pointer that returns the force at some time t). The continuous projectile algorithm started off easy enough. instead of: a(t) = F/m v(t) = Ft/m + v0 x(t) = Ft^2/(2m) + v0t + x0 the equations become: a(t) = F(t)/m v(t) = int(F dt)/m + v0 x(t) = int(int(F dt) dt)/m + v0t + x0 where int(F dt) is the integral of F with respect to t this works fine for any F(t) where the only variable in F is t. However, when I tried to use the simple air friction force equation, F=-b*v=-b*dx/dt, I ran into some problems. I solved for y using the differential equation: int(F dt) = -b*x y'(t) = x(t) y'(t) = y/m + v0t + x0 I got that x = m*v0/b which is a constant. I know this is wrong but I did the math write and plugging x back into the equations works. I think I might have the force function wrong because if G(t) = int(F dt) then G(0) should be 0 because v(0) = v0. However G(t) in this case isnt 0, its -b*x. 0 Share this post Link to post Share on other sites
erissian 727 Report post Posted October 9, 2006 For general motion, try to stick to r:(I don't know how to make dots and double dots, so " denotes second derivative wrt t)mr" = -br'r" + (b/m)r' = 0which can be solved with r' = A*exp(-bt/m)a more useful version would be to consider r' asr = -(A B)*exp(-bt/m)*(m/b)r' = (A B)*exp(-bt/m)*(b/m)r" = -(A B)*exp(-bt/m)*(b/m)where (A B) are arbitrary constants for the x and y vectors, respectively. 0 Share this post Link to post Share on other sites
michael879 100 Report post Posted October 9, 2006 Ive never even seen the dot notation for derivatives before today anyway, I use ' and ".ok how did you get a different answer than me? I solved for y in the equations:y' = randr = y/m + v0t + x0which is just the second derivative of the one you used..anyway, is there any way to generalize this to some set of functions F, G, H where G' = F and H' = G? I want to have a projectile class that takes three functions pointers and can calculate the position of the projectile at some time. If F is only a function of t what I have works but I dont see a way to include all functions of F..r" = F(t)/mr' = G(t)/m + v0r = H(t)/m + v0t + x0 0 Share this post Link to post Share on other sites
erissian 727 Report post Posted October 9, 2006 Well, what you're trying to solve in the resistance case is a differential equation. This is because F is essentially the second derivative of x, and is dependant on x.When solving a linear differential equation, it's common to use the exponetial function, or trigonometric functions, because their derivatives are in very much the same form.This case is essentially in the form of:x' + gx = 0So what functions of x would fit into this? Well, you can usually guarantee that the exponential function will. Let's say x is Ae^{bt}. The time derivative is bAe^{bt}. That makes our equation:bAe^{bt} + gAe^{bt} = 0Which reduces to:b + g = 0b = -gSo then we can rewrite this as:x = Ae^{-gt}In this case, we started with F as a function of x, and we can write it like this:F = ma = -bvWhere a = dv/dt = v'So, dividing both sides by m:v' = -(b/m)vv' + (b/m)v = 0Which is the same form as our x' + gx = 0 we had before.You can't just integrate over t, because F isn't dependant on t. You would still get stuck at this step:v(x) = -(b/m)xWhich again is the same form we used before, x' + gx = 0. 0 Share this post Link to post Share on other sites
chowe6685 349 Report post Posted October 9, 2006 For reference - in physics dots are usually used to denote derivatives with respect to time and ' is used to denote spatial derivatives. 0 Share this post Link to post Share on other sites
michael879 100 Report post Posted October 10, 2006 ok I guess what Im really asking is if I have a function F(v,x,t) and the derivitives and integrals of F if needed, what are r, r' and r"? Its impossible right? since the function F contains r and r'.. anyway I have one more question. Im currently taken diff. eq. and we havnt gotten to second differential non linear equations yet so can someone show me how to get r, r', and r" from F(t) = Gm/r^2 ?r^-2 * r" = GI tried taking the double integral of boths side, wtr r on the left, wtr t on the right. However I ended up with a polynomial answer which cant be right. Also, the solution I got has r'(0) = 0 and r"(0) = 0. 0 Share this post Link to post Share on other sites
michael879 100 Report post Posted October 10, 2006 ok I guess what Im really asking is if I have a function F(v,x,t) and the derivitives and integrals of F if needed, what are r, r' and r"? Its impossible right? since the function F contains r and r'.. anyway I have one more question. Im currently taken diff. eq. and we havnt gotten to second differential non linear equations yet so can someone show me how to get r, r', and r" from F(t) = Gm/r^2 ?r^-2 * r" = GI tried taking the double integral of boths side, wtr r on the left, wtr t on the right. However I ended up with a polynomial answer which cant be right. Also, the solution I got has r'(0) = 0 and r"(0) = 0. 0 Share this post Link to post Share on other sites
erissian 727 Report post Posted October 11, 2006 Well, it's not impossible, it's just a differential equation.Whenever you have a scenario like v(x) or a(x) or a(v), or any y^{(n)}(y^{(m)}), it's a differential equation.In the case of F = GMm/r^2, it's solvable by separation.(And once again, I'm using r" to represent d^{2}r/dt^{2})F = ma = -GMm/r^2(1) a = -GM/r^2Recognize that a is the time derivative of v:a = dv/dtUsing the chain rule:dv dv dr-- = -- --dt dr dtAlso, dx/dt = v, so:a = dv/dt = (dv/dr)(dr/dt) = (dv/dr)(v)(2) a = vdv/drUsing (1) and (2):vdv/dr = -GM/r^2vdv = -GM/r^2 drIntegrating:0.5 v^2 = +GM/rv = sqrt(2GM/r)So:r = rr' = sqrt(2GM/r)r" = -GM/r^2 0 Share this post Link to post Share on other sites