| 08-31-2006, 01:36 AM | #1 |
alright...damend me for taking 2 years off from math, I am having troubles here i need a function, in the form function blah takes real dist returns real that given: a number of function runs(25.) a final slide speed(.1) a total slide distance(dist) returns: the starting speed needed for this to occur for ex. i call the function call GetStartSpeed(50.) 50., being the total distance I want the unit to slide my slide timer runs every .03, for .75 secs, so 25. runs, and the end slide speed is .1(so the unit slows down) and it returns a real, say 8., which that, if I set the initial starting slide speed to this, the unit will slide for .75 secs(movement every .03 secs), from a starting speed of the returned real 8. to an end speed of .1, and will cover a total of 50, the real given to teh function, distance any help is appreciated gogo brain fart! |
| 08-31-2006, 02:20 AM | #2 |
This problem is undetermined with out knowing your diff eq, but I'm guessing that you're using a constant acceleration, such that Code:
a: acceleration v_i: initial speed v_f: final speed x_f: final distance t_f: final time ( function runs * timer period ) v(t) = at + v_i x(t) = at^2/2 + v_i t a = (v_f - v_i) / t_f v_i = (2 *x_f / t_f) - v_f Watch out for divisions by zero. |
| 08-31-2006, 02:34 AM | #3 |
maybe im not getting it yes i am using constant decelrration i want to solve for v_i (initial speed) so for ex. i want a distance of 50., over a time of .75 secs, with a final speed of .1 (2*50/.75)-.1 = 133.233 first it seems unlikly I could get the correct answer w/o acc. in the equation, and second, after some number crunching my init speed should be 3.9 what am I missing? |
| 08-31-2006, 02:41 AM | #4 |
Well it obviously has to be at least the average speed it would take to get from a to b (if you had no deceleration). That would be total distance / total time or 50 / .75 or a speed of 67. Since .1 is practically zero, you just need to go twice that fast to travel 50 while decelerating to zero in .75s (think area of a triangle) Your units are probably way off, since a speed of .1 is practically zero. |
| 08-31-2006, 03:21 AM | #5 |
I think the source of your confusion is that you are trying to solve for both acceleration and initial velocity at the same time. Just pick acceleration and then it is easy to solve for initial velocity: v0 = sqrt( vf*vf-2ax ) |
| 08-31-2006, 03:45 AM | #6 |
there enlies the problem, the acc, is based off the init vel. where a = (init vel-final vel) / (runs-1) :( |
| 08-31-2006, 06:10 AM | #7 |
Well, due to the fact acceleration is unknown, I used substitution with 2 equations I found on the same charts I used when I took AP Physics last year. ( http://www.collegeboard.com/prod_dow...ables_2002.pdf ). Bad thing is, 3/4's of that class we spent talking to the Teacher about various video games. Anyways, these two equations: Vf = Vo + at Vf^2 = Vo^2 + 2a(Xf - Xo) I substituted and ended up with this equation: (2(Xf-Xo))/t - Vf = Vo Where Xf = Final Position (Between these two,.. ) Xo = Initial Position ( Xf-Xo is the same as distance ) t = your # of runs I think Vf = Final Velocity (0.1) Vi = Starting Velocity But, this seems too easy, and I think I've done this before and my teacher became confuzzled for a while and than realized that one of the equations the variable isn't exactly what it seems. So if that happened with this same scenario, than this won't work. -.- Or if my Math just sucks.. XD |
| 08-31-2006, 06:23 AM | #8 |
Yep, that's right, nice to see we arrive at the same answer from different starting points. |
| 08-31-2006, 09:30 AM | #9 |
Ah, this reminds me of the equations I was dealing with when making the smooth cameras for my cinematic system. Fun times. Anyway, PipeDream is correct. And you really don't need much math to figure this out. |
| 09-01-2006, 07:41 AM | #10 |
Bleh, so you got an initial distance, breakdown distance, and interval whats the exact formula to calculate how much distance you want? Right now I got a function like KBUnit(unit,angle,interval,startdist,breakdist) I want to be able to use it while specifying max distance. any ideas? I didnt quite get what you guys were saying. |
| 09-01-2006, 10:49 PM | #11 |
*update yea I got it to work, Drain Pipe cleared it up for me that I was using the wrong units for time, instead of using the .75 secs, I should use 25, for the number of runs, which returns 3.9, which is what I got before when I did the number crunching to your question file, that is what i didi, what you want i had a final distance i wanted the unit to travel, after a set time at a set run speed, and a total distance, so those were my constants v_f = final distance t = time s = speed d = total distance wanted v_i = initial speed, which is what I wanted the first post Pipe had this, as did the other posted just using the formula (2 *x_f / t) - v_f , putting that in a function, which returns the answer, a real number that is the initial speed you want for example: you want to go to .01 distance, over 2 secs, at .03 runs/sec, and a total of 100 distance at a constant dec. : (2*100/(2/.03))-.01 = 2.99, would be your staring speed needed on another note, I had another idea I wanted to present: set a starting speed and an ending speed, a total time and a run speed, and have a function that return a % needed to take the starting speed down to the end speed in that time cuz I am kinda tired of the slides i have decelerating at a constant speed, i want it to be like an exponential decay, which I think would look better for ex. say u want to go from 10 - .1 distance, over 2 secs, at .03 secs/ run i would like a funcion that returned a percent, say .97, that would do that for me so each time, the slide distance gets 3% smaller (*.97) then the previous, so it would decay more lifelike I think, instead of at a constant rate, obviously this could never take a unit down to 0, but even .1 or .01 would be fine i dont think I have seen this done, but I would like to compare, when I ahve the time, the effects of each, to see if it would be worth it what do you think? |
