#### Archived

This topic is now archived and is closed to further replies.

# particles break apat, going up then down then bounces on the ground.., how?

This topic is 5933 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

hiya, i know how to make it go up, then i make it go down by subtracting it''s velocity with gravity * elapsed time; then i checked if(particle pos < 0.0f) // what do i do here? how would i make it slowly bounce till it stops? many thanks,

##### Share on other sites
I would think that after it hits the ground its velocity would be reversed and slowed down somewhat till it finally reaches zero.

##### Share on other sites
Since you should know the speed of the particle as it passes the ground, I would just revers the direction, and cut the speed in half. Thus each time it bounces it will only bounce half as high. When the speed gets low enough that it doesn''t appear to the eye that it bounces, I would either delete it, or set it''s velocity to zero. Depending on if you want it to stay there on the ground or not.

##### Share on other sites
wow, thanks it works

off topic... in physics, what does this thing resolve too?

velocity += accelaration * elpasedtime
position += velocity * elpasedtime;

i mean, why are movement done like those?

thanks,

##### Share on other sites
By definition, its:

v = a * t
s = v * t

where

v is speed
a is accelleration
s is position
t is time

This is the reason why speed is measured in meters per second, or miles per hour if you like that better (s = v * t => v = s / t).

When you do step-wise simulation, it comes to the following formulae:

v(t + delta_t) = v (t) + a(t) * delta_t
s(t + delta_t) = s (t) + v(t) * delta_t

where

delta_t is elapsed time
and v(t) meaning speed at time t

if you break it down to C code, it yields your formulae.

The simplification done here, of course, is that acceleration
is considered constant during the period delta_t.

Hope that helps.

Tilmann

##### Share on other sites
quote:
Original post by mickey
wow, thanks it works

off topic... in physics, what does this thing resolve too?

velocity += accelaration * elpasedtime
position += velocity * elpasedtime;

i mean, why are movement done like those?

thanks,

It boils down to a bit of calculus. Lets simplify your symbols. Let a = acceleration, v = velocity, s = position, t = time. (s is sort of a traditional symbol for distance.)

acceleration, by definition is equal to:

a = dv/dt

That d*/d* notation represents a "derivative" which is basically the slope of a curve. acceleration is the slope of the velocity curve. Now, using what is called finite differences, you can approximate the value of dv/dt by the following formula:

dv/dt = (approx.) (v(t + ellapsedtime) - v(t)) / ellapsedtime

That v(t + ellapsedtime) is just exactly what you''re calculating when you do velocity += acceleration*ellapsed time. That is, rearrangging my equation, you get:

v(t+ellapsedtime) = (dv/dt)*ellapsedtime + v(t)which, since dv/dt = a, is exactly:v(t+ellapsedtime) = a*ellapsedtime + v(t)

Now, you never keep track of the value of v at different times. You just use one variable, velocity, but in effect when you update velocity you are taking the current velocity and adding a*ellapsedtime to get the new velocity.

Position is the same. By definition, using calculus, v = ds/dt, which using finite differences is approximated as:

ds/dt = (approx.) (s(t+ellapsedtime) - s(t))/ellapsedtime

Now the particular approximations to ds/dt and dv/dt used above lead to what is known as "simple Euler integration" or "explicit Euler integration." Integration, or numerical integration, is the process of updating a variable based on a previous time step. The simple Euler integration method is one of the simplest, and also one of the most problematic. It can lead to instability, e.g., overflow, etc., in some cases. As you continue to learn how to do physics simulation, you''ll learn about things like "Runge Kutta," "verlet," "predictor-corrector," and other types of integration. Its usually easiest to implement an algorithm using Euler, but often it is necessary to user another method, very often verlet or Runge-Kutta, to resolve problems. These other methods are also based on finite differences. Finite differences, in turn, are based on the use of the Taylor series expansion----a core theorem of basic calculus.

Graham Rhodes
Senior Scientist
Applied Research Associates, Inc.

##### Share on other sites
I suppose that''s a good example of Calculus in a nutshell

##### Share on other sites
wow thanks, well, as of now, i won''t be able to 100% appreciate what you guys just explained to me, but maybe after a few more readings later, i would then clearly understand what you guys just told me now. but still thanks very much for these explainations,

##### Share on other sites
quote:
Original post by sgt_barnes
By definition, its:

v = a * t
s = v * t

Just to be sure you''re straight on this....these formulas are not definitions. They''re really just approximate formulas that are derived from the finite difference approximation to dv/dt and ds/dt as I describe in my other post. . And t isn''t absolute time. It is the elapsed time since a, v, and s were last evaluated.

Graham Rhodes
Senior Scientist
Applied Research Associates, Inc.

1. 1
2. 2
Rutin
16
3. 3
4. 4
5. 5

• 26
• 11
• 9
• 9
• 11
• ### Forum Statistics

• Total Topics
633704
• Total Posts
3013460
×