Speed of the knockback is <= 0

  • Thread starter wraithseeker
  • Start date
  • Tags
    Speed
In summary: Object Bvelocity = vx,vy,vz (any numbers will do)acceleration = ax,ay,az...position = px,py,px...time period = t (0.03 seconds in the example)In summary, the conversation is about two objects moving in space, and the first object's velocity, acceleration, and position are all calculated every 0.03 seconds. Additionally, the second object's velocity, acceleration, and position are also calculated every 0.03 seconds, but the second object's average velocity is 1/2 of the
  • #1
wraithseeker
29
0
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 until 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?
 
Physics news on Phys.org
  • #2


This is possibly a stupid question, but... what is a "knockback"? :confused:
 
  • #3


knockback?
I assume this is like an angled trampoline for a ball. The USA name for this is a pitchback:

http://www.sportsworldwholesalers.com/2770fs.html

wraithseeker said:
So How would I go about doing a perfect parabola?
Using parametric equations:

Position:

Px(t) = Vx t + Px0
Py(t) = 1/2 Ay t2 + Vy0 t + Py0

Velocities:

Vx(t) = Vx
Vy(t) = Ay t + Vy0

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:

Vn+1 = Vn + 1/2 (An+An+1) Δ t

In this case, since acceleration is a constant, you just end up with the known equations for velocities. Position calculations become:

Pn+1 = Pn + 1/2 (Vn+Vn+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

Predictor-corrector_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 V0 and position P0.
 
Last edited by a moderator:
  • #4


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


wraithseeker said:
is T time or is T timeframe?
T is elapsed time, Δt is time step. I don't know what you mean by time frame.
 
  • #6


I'm doing some sort of programming and I have to move a object by a timeframe which let's 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


wraithseeker said:
I'm doing some sort of programming and I have to move a object by a timeframe which let's 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?

first one should be:

velocity.z = velocity.z + acceleration.z * (timeperiod)

I don't know why did you multiply initial velocity by the timeperiod.
That's part of the formula for position. (note - I editted my previous post to clean up the names in the formulas.)

If acceleration is constant:

Δt = t1 - t0

initial velocity = Vy0
final velocity = Vy1= Vy0 + Ay Δt
average velocity = 1/2 (Vy0 + Vy1) = 1/2 (Vy0 + (Vy0 + Ay Δt)) = Vy0 + 1/2 Ay Δt

initial position = Py0
final position = Py0 + (average velocity) Δt = Py0 + (Vy0 + 1/2 Ay Δt) Δt = Py0 + Vy0 Δt + 1/2 Ay Δt2
 
Last edited:
  • #8


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.
 
Last edited:
  • #9


wraithseeker said:
I don't understand much of why are you using average velocity.
Say a vehicle is experiencing constant acceleration. At time t0 the vehicle is moving at 30 kph, one second later, at time t1, the vehicle is moving at 50kph. How much distance (position) the vehicle travel during this time?

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).
 
Last edited:
  • #10


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

Which should I use?

Say a vehicle is experiencing constant acceleration. At time t0 the vehicle is moving at 30 kph, one second later, at time t1, the vehicle is moving at 50kph. How much distance (position) the vehicle travel during this time?

To solve this type of problem you use distance = average velocity x time.

Or

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).

I am abit confused by those 2 statements.
 
  • #11


wraithseeker said:
Do I do them for the x y z coordinates or just the z coordinates?
You can do them for all coordinates, but velocity only changes where there is acceleration, and in your example acceleration only occurs on the z axis. Calculating the average velocity when it's not changing still works. If the velocity is 30kph at the start and 30kph at the end, than average velocity = 1/2 (30 + 30) = 30, so might as well be consistent and use the same method for x, y, and z, while noting that acceleration only occurs on the z axis.

Jeff Reid said:
Say a vehicle is experiencing constant acceleration. At time t0 the vehicle is moving at 30 kph, one second later, at time t1, the vehicle is moving at 50kph. How much distance (position) the vehicle travel during this time?

To solve this type of problem you use distance = average velocity x time.
confused
The initial speed of the vehicle is 30 kph, the final speed is 50 kph, the average speed = 1/2 (30 + 50) = 40 kph.

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).
confused

http://en.wikipedia.org/wiki/Trapezoidal_rule

In your case, we can calculate velocity based on elapsed time, so given Vz0, Vz1 can be calculated via Vz1 = Vz0 Az x Δt. The "a" used in the wiki article would be Vz0, and the "b" would be Vz1.

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 = -V2 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.
 
Last edited:
  • #12


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 V2 where c is some constant.

Initial state V0

Time step = Δt

A0 = -c V02

Make first guess assuming A is constant:
Ag 1 = A0

Calculate a velocity guess based on average acceleration
Vg 1 = V0 + 1/2 (A0 + Ag 1) Δt

Make a new guess for A based on Vg1
Ag 2 = A(Vg 1) = -c Vg 12

Calculate another velocity guess based on average acceleration
Vg 2 = V0 + 1/2 (A0 + Ag 2) Δt

If Δt is small enough that an inflection point isn't an issue, this process will converge, so repeat this process:
Ag n+1 = A(Vg n)
Vg n+1 = V0 + 1/2 (A0 + Ag n+1) Δt

Until | Ag n+1 - Ag n | < some tolerance factor.

You can put a limit on this, if | Ag n+1 - Ag 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

A1 = Ag n+1
V1 = Vg 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.
 
Last edited:
  • #13


I tried to use this one on your post above

Δt = t1 - t0

initial velocity = Vy0
final velocity = Vy1= Vy0 + Ay Δt
average velocity = 1/2 (Vy0 + Vy1) = 1/2 (Vy0 + (Vy0 + Ay Δt)) = Vy0 + 1/2 Ay Δt

initial position = Py0
final position = Py0 + (average velocity) Δt = Py0 + (Vy0 + 1/2 Ay Δt) Δt = Py0 + Vy0 Δt + 1/2 Ay Δt2

But it ended up backfiring.

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


wraithseeker said:
initialization before throwing
s = speed
Inside Timeframe function

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

s = initial speed.z

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


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


wraithseeker said:
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.
Note that gravity is negative. It's -9.80665 meters/second2 or -32.174 feet / second2.
 
  • #17


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


wraithseeker said:
Gravity is -981 since it's converted to the game's units. What about that time variable that gets increased in the timeframe function?
The time variable isn't being used in the other equations. You'd might use it to make a graph of position or velocity versus time.
 
  • #19


Well that was actually what I was doing all along. timeframe was timestep actually, I think you misunderstood.

Right now I am using a parbolic equation that calculates things and allows people to specify a maxheight but there will no longer be any gravity.

function ParabolaZ2_v2 takes real y0, real y1, real h, real d, real x returns real
return ((4 * h / d) * (d - x) + y1 - y0) * (x / d) + y0
endfunction

y0 = initial z coordinate of object
y1 = z coordinate at end of the ball
h = maxheight
d = distance
x= distance travelled

It makes the thrown ball drop exactly when the velocity is 0 but the old one doesn't and I was wondering if it was possible to do it with physics.
 
  • #20


I understood that timeframe was timestep or delta time. I don't understand why there is a parabola if there's no gravity. I don't understand what your parabola function is trying to calculate.
 
  • #21


It was slowly done from a quadratic equation.

The general parabola function looks something like this:
f(x) = a * x^2 + b * x + c

Obviously, it's unusable.
Well, given sufficient motivation, it will most likely work out nicely.
Still, way too many constants to deal with... let's look for something simpler.

We want to determine y, given the current x, between 0 and some max distance, such that y is heighest "in the middle".
Let's call that distance d and the height h.

It follows that:
On x = 0, y will be 0 too, that's the starting point.
Same when x = d, the max distance we want here, y = 0 too in that case. We have landed back on the ground.
And, in the middle, i.e. when x = d / 2, we want the heighest point, i.e. y = h.

Given that d / 2 is a point of interest, where the function starts to "turn around",
a good starting point for a formula is
x - d/2

We also want this to be curvy, so let's add some square to that:
(x - d/2)^2

Additionally, that also makes sure we get the same result for x between 0 to d/2 and x between d/2 to d.
Yes, math can be all the fun really...

That needs some scaling factor too:
a * (x - d/2)^2

Why does it need one?
Because we want to add the max height here.
Multiplying that expression by a constant is a good way to get proportionally smaller or higher values while still being simple to calculate.

When x = d / 2 that expression will be 0 and we want y to be h at that point.

We end up with:
y = a * (x - d/2)^2 + h

Is that even a valid formula for a parabola?

Well, yes, it is.
That's the so called "standard form".
(For details, see "Forms of ...": http://en.wikipedia.org/wiki/Quadratic_function)


Makes all the sense until here
And, yes, we might just as well have started there... but, hey, where's the fun in that?


a * (x - d/2)^2 + h = y

Looks good.
We know x, d and h. y will be calculated.

What's "a" though?
No idea...

But, we know that y = 0 if x is either 0 or d.

Let's plug that in (x = d and y = 0):

If x = d, then (x - d/2)^2 = (d - d/2)^2 = (d/2)^2 = d^2 / 4

We get,
a * d^2 / 4 + h = 0
a * d^2 + 4 * h = 0
a = -4 * h / d^2

Back to the original "standard form":
y = h - (x - d/2)^2 * 4 * h / d^2

Simple test, assuming that d = 10, h = 3:
y = 3 - (x - 5)^2 * 12 / 100
With x = 0: 3 - 25 * 12 / 100 = 3 - 12 / 4 = 3 - 3 = 0 q.e.d.
With x = d = 10: 3 - (10 - 5)^2 * 12 / 100 = 3 - 25 * 12 / 100 = 0 q.e.d.
With x = d / 2 = 5: 3 - 0 = 3 = h q.e.d.

Holds so far.
And looks like a usable formula already.

Now, there's still plenty of divisions and squares there.
With any luck, something simpler will show up if we try long enough...

(It's mostly long because I did it in really small steps)
y = h - (x - d/2)^2 * 4 * h / d^2
= h - (x^2 - 2 * x * d / 2 + d^2 / 4) * 4 * h / d^2
= h - (x^2 - x * d + d^2 / 4) * 4 * h / d^2
= h - x^2 * 4 * h / d^2 + x * d * 4 * h / d^2 - 4 * h * d^2 / 4d^2
= h - x^2 * 4 * h / d^2 + 4 * h * x / d - h
= 4 * h * x / d - 4 * h * x^2 / d^2
= 4 * h * x * d / d^2 - 4 * h * x^2 / d^2
= (4 * h * x * d - 4 * h * x^2) / d^2
= 4 * h * x * (d - x) / d^2

Want shorter?
y = h - (x - d/2)^2 * 4 * h / d^2
= h - 4 * h * x^2 / d^2 - 4 * h * (d/2)^2 / d^2 + 4 * h * 2 * x * (d/2) / d^2
= h - 4 * h * x^2 / d^2 - h + 4 * h * x / d
= 4 * h * x * (1/d - x /d^2)
= 4 * h * x * (d - x) / d^2

Result:
y = 4 * h * x * (d - x) / (d * d)

One division only, the rest a couple multiplications and one subtract.
Looks good.

Same test as before, d = 10, h = 3:
y = 4 * 3 * x * (10 - x) / 100
y = 12 * x * (10 - x) / 100

x = 0 => y = 0
x = 10 <=> 10 - x = 0 => y = 0
x = d / 2 = 10 / 2 = 5 <=> y = 12 * 5 * 5 / 100 = 12 * 25 / 100 = 12 / 4 = 3 = h q.e.d.
 
  • #22


Jeff Reid said:
I don't understand what your parabola function is trying to calculate.

wraithseeker said:
It was slowly done from a quadratic equation.
What I meant is what physical property is it trying to emulate? Previously you were talking about a parabolic path due to gravity for the knockback, but now you're generalizing it to the "standard form". I don't understand the goal you're trying to achieve here.

Initially, I though it was meant as a simple means to test an algorithm for numerical integration, but now you're talking about a parabolic function with no time factor, just y versus x, instead of y and x versus time.
 
  • #23


It returns the height needed for the timestep, it's hard to explain, I didn't make that equation.
 
  • #24


wraithseeker said:
It returns the height needed for the timestep, it's hard to explain, I didn't make that equation.
Using the math you started with, then you just need to assign an iniitial vertical velocity:

Vz0 = +sqrt(2 x (-Az) x height)

Vz0 = +sqrt(2 x 981 x height)

The time it takes to reach the peak height with initial Vz0 is the time it takes for Vz to equal zero. (Az = -981):

Vz = Vz0 + Az tp = 0
tp = Vz0/(-Az) = sqrt(2 x 981 x height) / 981 = sqrt(2 x height / 981)

The time it takes to return to the ground is
t = 2 x tp = 2 x sqrt(2 x height / 981)

To cover distance x in this time:
Vx = distance.x / t

To cover distance y in this time:
Vy = distance.y / t
 
Last edited:

1. What does "speed of the knockback is <= 0" mean?

The phrase "speed of the knockback is <= 0" refers to a situation where the force that propels an object backwards, known as knockback, has a speed of zero or less. This means that the object is not moving or is moving in the opposite direction of the knockback force.

2. What causes the speed of the knockback to be <= 0?

There are several factors that can cause the speed of the knockback to be <= 0. This can include the object being too heavy to be moved by the knockback force, the object being anchored or fixed in place, or the knockback force being too weak to overcome the object's inertia.

3. Can the speed of the knockback be negative?

Yes, the speed of the knockback can be negative, which indicates that the object is moving in the opposite direction of the knockback force. This can happen if the object has its own momentum or if there is an opposing force acting on it.

4. How is the speed of the knockback measured?

The speed of the knockback is typically measured in meters per second (m/s) or feet per second (ft/s). This is determined by dividing the distance the object moves backwards by the time it takes to move that distance.

5. Why is it important to understand the speed of the knockback being <= 0?

Understanding the speed of the knockback being <= 0 is important for several reasons. It can help us analyze the forces acting on an object and determine why it is not moving, and it can also help us predict the movement of objects in the future. Additionally, understanding the speed of the knockback is important in fields such as physics, engineering, and sports where the movement of objects is a crucial factor.

Similar threads

Replies
6
Views
894
Replies
24
Views
1K
  • Mechanics
Replies
11
Views
2K
Replies
9
Views
904
Replies
4
Views
843
Replies
15
Views
1K
  • Mechanics
Replies
3
Views
542
Replies
8
Views
392
Replies
26
Views
1K
Back
Top