Register to reply 
Speed of the knockback is <= 0 
Share this thread: 
#1
Jul809, 03:07 AM

P: 29

I can explain them by 2 ways, I am making some sort of a game. I am doing a some sort of a knockback but the unit will be flying.
Imagine that the knockback ends only when the speed of the knockback is <= 0 and there is decrement & speed which is user specified. The unit is moved by a timeframe of 0.03 seconds and gravity = 981. I know it is initially 9.81 but in the game it is calculated as 981. Every 0.03 seconds untill speed <= 0, speed is constantly reduced by decrement and how would I go about making the unit perform a parabola from point A (initial position of the unit) to point B(final area). I do not really know how to calculate distance with speed and decrement but is it like 1 * speed * speed / (2 * decrement / Timeframe) And I want to know how can I get the time of the knockback. ??? In another way I could say it like unit A has 3 vectors. Vector position, acceleration and velocity(They get updated every timeframe). Position stores the position of the unit and acceleration is actually deacceleration as it is negative. Velocity is just initial speed of the unit and gets decreased every timeframe by acceleration. Velocity vector adds the acceleration and then Position vector adds the velocity every timeframe. The knockback would end when the dotproduct of velocity and acceleration >= 0. Distance used to calculate is the same as the following one above. So How would I go about doing a perfect parabola? 


#2
Jul1109, 04:17 AM

Mentor
P: 11,625

This is possibly a stupid question, but... what is a "knockback"?



#3
Jul1109, 05:07 PM

HW Helper
P: 7,047

http://www.sportsworldwholesalers.com/2770fs.html Position: Px(t) = Vx t + Px_{0} Py(t) = 1/2 Ay t^{2} + Vy_{0} t + Py_{0} Velocities: Vx(t) = Vx Vy(t) = Ay t + Vy_{0} Accelerations: Ax(t) = 0 Ay(t) = 981 In the classical numerical integration case, you only know the equations for acceleration for a given set of velocities and positions, but this is a case where the equations for velocities and position are also known. The acceleration equations, combined with initial velocities and positions, are what you need to create a parbola using numerical integration. Since the integrals of acceleration and velocities are known equations, you can use these to confirm your method of numerical integration In cases like this one, where acceleration is constant or can be calculated based on time without knowing velocities or position, an averaging method can be used if the steps are small enough: V_{n+1} = V_{n} + 1/2 (A_{n}+A_{n+1}) Δ t In this case, since acceleration is a constant, you just end up with the known equations for velocities. Position calculations become: P_{n+1} = P_{n} + 1/2 (V_{n}+V_{n+1}) Δ t Again, because acceleration is a constant, position calculations will also end up as the known equations for positions. Post #8 shows this for Py. Numerical_intergration_wiki.htm Predictorcorrector_wiki.htm Runge_Kutta_wiki.htm A more classic example of numerical intergration produces a sine or cosine wave using: A = P Along with initial velocity V_{0} and position P_{0}. 


#4
Jul1109, 10:28 PM

P: 29

Speed of the knockback is <= 0
is T time or is T timeframe?
initial position z = the height of the object initial acceleration = 981/2 in the timeframe function itself (TIME = TIMEFRAME) velocity.z = GRAVITY + (TIME*TIME) + acceleration.z* TIME position.z = position.z + velocity.z 


#5
Jul1109, 10:39 PM

HW Helper
P: 7,047




#6
Jul1109, 10:49 PM

P: 29

I'm doing some sort of programming and I have to move a object by a timeframe which lets say is 0.03.
velocity.z = velocity.z + acceleration.z * (timeperiod*timeperiod) position.z = position.z + velocity.z * timeframe timeperiod = timeperiod + timeframe Here are my current calculations, are they correct? I don't know why did you multiply initial velocity by the timeperiod. 


#7
Jul1209, 12:45 AM

HW Helper
P: 7,047

velocity.z = velocity.z + acceleration.z * (timeperiod) If acceleration is constant: Δt = t_{1}  t_{0} initial velocity = Vy_{0} final velocity = Vy_{1}= Vy_{0} + Ay Δt average velocity = 1/2 (Vy_{0} + Vy_{1}) = 1/2 (Vy_{0} + (Vy_{0} + Ay Δt)) = Vy_{0} + 1/2 Ay Δt initial position = Py_{0} final position = Py_{0} + (average velocity) Δt = Py_{0} + (Vy_{0} + 1/2 Ay Δt) Δt = Py_{0} + Vy_{0} Δt + 1/2 Ay Δt^{2} 


#8
Jul1509, 08:02 AM

P: 29

I don't really get some parts understood but I think I got some part of it right.
Object A velocity = vx,vy,vz (any numbers will do) acceleration = ax,ay,az ( any number will do except az which is gravity*0.5 like you said) distance = the distance covered by the ball time = distance/(speed/2) (Finding the distance covered by the ball when thrown) Position vector is available but not random numbers. Current calculations in the timeframe are as followed vx = vx + ax vy= vy + ay vz = vz + az * timeframe px = px + vx * timeframe py = py + vy * timeframe pz = pz + vz * timeframe If you do not know what the variables mean, they are; velocity vector = vx,vy,vz position vector = px,py,pz acceleration vector = ax,ay,az. Final velocity are all 0. I don't understand much of why are you using average velocity so I posted this. To sum it up, how would I do a parabola if velocity z can be inputted by any number? Setting it higher or lower makes it look stupid. 


#9
Jul1609, 04:18 PM

HW Helper
P: 7,047

To solve this type of problem you use distance = average velocity x time. For numerical integration, one simple method is to use linear interpolation for each interval, change in position = "average" velocity x time step, this the equivalent of "trapezoidal" rule (for finding area under a curve). 


#10
Jul1709, 04:06 AM

P: 29

Do I do them for the x y z coordinates or just the z coordinates?
Which should I use? 


#11
Jul1709, 05:49 PM

HW Helper
P: 7,047

In your case, we can calculate velocity based on elapsed time, so given Vz_{0}, Vz_{1} can be calculated via Vz_{1} = Vz_{0} Az x Δt. The "a" used in the wiki article would be Vz_{0}, and the "b" would be Vz_{1}. Note that this type of numerical integration only works when acceleration is function of time. If acceleration is a function of velocity and position, then standard numerical integration methods are required. For a simplified aerodyamic drag equation, A = V^{2} is a better example, although it's simple enough to integrate directly. I already mentioned A = P which generates a sine wave as another example. 


#12
Jul1709, 07:27 PM

HW Helper
P: 7,047

Here is an example of a crude "predictor corrector" algorithm. To simplify things, I'll use an example that where only one level of integration is required, such as A = c V^{2} where c is some constant.
Initial state V_{0} Time step = Δt A_{0} = c V_{0}^{2} Make first guess assuming A is constant: A_{g 1} = A_{0} Calculate a velocity guess based on average acceleration V_{g 1} = V_{0} + 1/2 (A_{0} + A_{g 1}) Δt Make a new guess for A based on V_{g1} A_{g 2} = A(V_{g 1}) = c V_{g 1}^{2} Calculate another velocity guess based on average acceleration V_{g 2} = V_{0} + 1/2 (A_{0} + A_{g 2}) Δt If Δt is small enough that an inflection point isn't an issue, this process will converge, so repeat this process: A_{g n+1} = A(V_{g n}) V_{g n+1} = V_{0} + 1/2 (A_{0} + A_{g n+1}) Δt Until  A_{g n+1}  A_{g n}  < some tolerance factor. You can put a limit on this, if  A_{g n+1}  A_{g n}  is not less than the tolerance factor after some specific number of steps, say 16, then decrease Δt and repeat the step. If convergence occurs in less than say 4 steps, increase Δt. Then you start a new step using A_{1} = A_{g n+1} V_{1} = V_{g n+1} This is a crude process but most of the methods require generating a few initial steps before the iteration (looping) process can be eliminated. This iterative process could also be used with the better algorithms listed in the links above for each step. 


#13
Jul1809, 10:43 AM

P: 29

I tried to use this one on your post above
initialization before throwing s = speed Inside Timeframe function set position.z = position.z + s*time+0.5*GRAVITY*(time*time) set time = time  timeframe 


#14
Jul1809, 05:39 PM

HW Helper
P: 7,047

set position.z = position.z + s*timeframe+0.5*gravity*(timeframe*timeframe) set time = time + timeframe 


#15
Jul1809, 09:58 PM

P: 29

Yep, s is initial speed z, I probably didn't get it clear for you sorry.
time is actually the full time for the thrown ball but now edited to be 0 at start. position.z = position.z + s*timeframe+0.5*GRAVITY*(timeframe*timeframe) time = time + timeframe So how can time fit in now? I followed your example above and objects launched in the air never gets down. 


#16
Jul1909, 12:12 AM

HW Helper
P: 7,047




#17
Jul1909, 12:21 AM

P: 29

Gravity is 981 since it's converted to the game's units.
What about that time variable that gets increased in the timeframe function? 


#18
Jul1909, 12:32 AM

HW Helper
P: 7,047




Register to reply 
Related Discussions  
Help with parabola  Precalculus Mathematics Homework  3  
Equation of the family of parabolas having fixed directrix  General Math  0  
Find a point on the axis of a parabola  Precalculus Mathematics Homework  4  
Parabola Help Plz  Introductory Physics Homework  1  
Equation for he indicated parabola  General Math  6 