POV-Ray : Newsgroups : povray.advanced-users : Flying and bouncing debris Server Time
29 Jul 2024 12:17:11 EDT (-0400)
  Flying and bouncing debris (Message 3 to 12 of 12)  
<<< Previous 2 Messages Goto Initial 10 Messages
From: J  Diehl
Subject: Re: Flying and bouncing debris
Date: 30 Aug 2002 03:25:03
Message: <web.3d6f1d5fd26a61b2f70c33440@news.povray.org>
Try to model a bouncing ball on a plane with varibales for different maximum
height and horizontal speed (the function will always be a parable).
Then use multiple balls starting from origin in different directions with
random size, maximum height and horizontal speed, while the combination of
height and speed should depend on the mass (size) of each.
Last, replace the balls by rotating pieces of debris and you should get a
nice impact.
There is no collision detection between the pieces themselves or any
heightfield on the ground.
A simple idea how to form a crater in the ground with heightfields see your
"meteorite impact" post.

These are very simple and just 'look alike' simulations of an impact. For a
realistic simulation you will have to study dynamics. Have a look at

(Jul 15th 2002) and at his animations at
http://www-public.tu-bs.de:8080/~y0013390/pov/sim/index.html
Watch his water interaction - it reminds me of an impact...


Post a reply to this message

From: Christopher James Huff
Subject: Re: Flying and bouncing debris
Date: 4 Sep 2002 20:12:23
Message: <chrishuff-6C2962.20114404092002@netplex.aussie.org>
In article <3D6D7B3D.92EFB361@pacbell.net>, Ken <tyl### [at] pacbellnet> 
wrote:

> Other people in these groups have been working on particle systems but
> I don't recall anyone releasing them for public use and remain in private
> hands.

I released a particle system patch. There was another particle patch of 
some sort, but I don't know if it was just a particle object or an 
actual particle system, or what kind of capabilities it had (even though 
I included it in MegaPOV+ alongside my own patch). These are pretty out 
of date though.

-- 
Christopher James Huff <cja### [at] earthlinknet>
http://home.earthlink.net/~cjameshuff/
POV-Ray TAG: chr### [at] tagpovrayorg
http://tag.povray.org/


Post a reply to this message

From: Rohan Bernett
Subject: Re: Flying and bouncing debris
Date: 15 Sep 2002 20:30:06
Message: <web.3d852586d26a61b2d02c7b870@news.povray.org>
J. Diehl wrote:
>Try to model a bouncing ball on a plane with varibales for different maximum
>height and horizontal speed (the function will always be a parable).
>Then use multiple balls starting from origin in different directions with
>random size, maximum height and horizontal speed, while the combination of
>height and speed should depend on the mass (size) of each.
>Last, replace the balls by rotating pieces of debris and you should get a
>nice impact.

So how would I create a means for simulating the neccessary system? What I
think I'd need would be a way to specify an initial position and velocity
and a force of gravity. Then a way of specifying how much the object
bounces when it hits the ground, and how many bounces it takes before it
stops. A rock from a meteorite impact, for example, would go up with a very
large velocity, but bounce to only, say, 1 metre on the first bounce, then
a couple of centimetres on the second, then stop.

If anyone can tell me of any way to do this, I'd be very grateful.

Rohan _e_ii


Post a reply to this message

From: Christopher James Huff
Subject: Re: Flying and bouncing debris
Date: 15 Sep 2002 21:01:24
Message: <chrishuff-C2F8F7.21000515092002@netplex.aussie.org>
In article <web.3d852586d26a61b2d02c7b870@news.povray.org>,
 "Rohan Bernett" <rox### [at] yahoocom> wrote:

> So how would I create a means for simulating the neccessary system? What I
> think I'd need would be a way to specify an initial position and velocity
> and a force of gravity. Then a way of specifying how much the object
> bounces when it hits the ground, and how many bounces it takes before it
> stops. A rock from a meteorite impact, for example, would go up with a very
> large velocity, but bounce to only, say, 1 metre on the first bounce, then
> a couple of centimetres on the second, then stop.

Try just using a scale factor for the percentage of kinetic energy the 
ball keeps after bouncing. A superball (high-bounce synthetic rubber 
ball) would be around 0.9, a rock more like 0.05. Take both the object 
and the surface it hits into account (maybe the average of both 
"elasticity" values). If you want a "stop" point, consider it stopped 
when the speed (length of the velocity vector) drops below a certain 
threshold.

-- 
Christopher James Huff <cja### [at] earthlinknet>
http://home.earthlink.net/~cjameshuff/
POV-Ray TAG: chr### [at] tagpovrayorg
http://tag.povray.org/


Post a reply to this message

From: Rohan Bernett
Subject: Re: Flying and bouncing debris
Date: 19 Sep 2002 01:00:05
Message: <web.3d895918d26a61b218ccf4f70@news.povray.org>
Christopher James Huff wrote:

>Try just using a scale factor for the percentage of kinetic energy the
>ball keeps after bouncing. A superball (high-bounce synthetic rubber
>ball) would be around 0.9, a rock more like 0.05. Take both the object
>and the surface it hits into account (maybe the average of both
>"elasticity" values). If you want a "stop" point, consider it stopped
>when the speed (length of the velocity vector) drops below a certain
>threshold.

A code example would certainly help, and some info to go with it would help
even more. I haven't had any experience in physics simulations, yet. I have
made some simple animations of objects moving along splines, and a falling
sphere, though.

Rohan _e_ii


Post a reply to this message

From: Tim Nikias
Subject: Re: Flying and bouncing debris
Date: 19 Sep 2002 04:08:42
Message: <3d89860a$1@news.povray.org>
Here are some equations you'll gonna need:

Considering Direct_Speed is the direction
the particle is flying with the vectorlength
representing the velocity the particle has,
Gravity being the amount of Gravity (in
m/s this'd 9.81), the path is calculated
like this:

Actual_Position=Starting_Position+Direct_Speed*Time-y*.5*Gravity*pow(Time,2)
;

To calculate a rebounce-position, you calculate when the y-component
reaches 0 (the height where the plane'd be) like this:

Hit_Time=-(Direct_Speed.y/Gravity)-sqrt(
pow(Direct_Speed.y/Gravity,2)+((2*Starting_Position.y)/Gravity) );

To make it clear what I've done: I just resolved the topmost equation for
the y-component and T. Since the equation looks like this:

we can change this to

which is the same as

and then we can use

t = -(p/2) +- sqrt( pow((p/2),2) + q )

So, when we now the instant the object hits the floor again, we need only
the
speed, and direction of flight at that instant. Then we multiply that vector
with <1,-1,1> to rebounce from the floor and multiply with some float (.9)
to lose some kinetic energy.
What's the direction/speed-vector?

Actual_Direction_Speed = Direction_Speed + Time*Gravity*y;

So, after we've calculated the time of hit, we can also calculate the
location by just putting the time back into the first equation. Then
we've got all we need: A new initial starting location, a new
speed and direction... And we can continue with the loop.

To do this properly in POV-Ray, you should set a loop
which checks the next hit (time). If a POV-Ray-Variable,
which keeps track of time (like clock*20 for 20 seconds),
is larger than the hit-time you calculated, the hit occured, and
the loop is run again.

I'll implement the code and send another reply then,
but you should get working already...

Regards,
Tim



--
Tim Nikias
Homepage: http://www.digitaltwilight.de/no_lights/index.html
Email: Tim### [at] gmxde
"Rohan Bernett" <rox### [at] yahoocom> schrieb im Newsbeitrag
news:web.3d895918d26a61b218ccf4f70@news.povray.org...
> Christopher James Huff wrote:
>
> >Try just using a scale factor for the percentage of kinetic energy the
> >ball keeps after bouncing. A superball (high-bounce synthetic rubber
> >ball) would be around 0.9, a rock more like 0.05. Take both the object
> >and the surface it hits into account (maybe the average of both
> >"elasticity" values). If you want a "stop" point, consider it stopped
> >when the speed (length of the velocity vector) drops below a certain
> >threshold.
>
> A code example would certainly help, and some info to go with it would
help
> even more. I haven't had any experience in physics simulations, yet. I
have
> made some simple animations of objects moving along splines, and a falling
> sphere, though.
>
> Rohan _e_ii
>


Post a reply to this message

From: Tim Nikias
Subject: Re: Flying and bouncing debris
Date: 19 Sep 2002 04:12:59
Message: <3d89870b$1@news.povray.org>
Oops, that should be

Actual_Direction_Speed = Direction_Speed - Time*Gravity*y;

not plus (+) Gravity.

--
Tim Nikias
Homepage: http://www.digitaltwilight.de/no_lights/index.html
Email: Tim### [at] gmxde


Post a reply to this message

From: Tim Nikias
Subject: Re: Flying and bouncing debris
Date: 19 Sep 2002 05:17:26
Message: <3d899626@news.povray.org>
Hm. Somehow I can't get the code to work, though I implemented
just that in my particle system. I've got a headache (due to a
flu), so I'm not really up to it now. Still, the equations you need
are the same:

Position = Initial_Position+ Direct_Speed*Time - y*.5*Gravity*Time*Time;
Speed = Direct_Speed -y*Gravity*Time;

All you need to do is modify the equations in order to find the
exact time when the particle hits the ground again, then calculate
the speed and position of impact, multiply the new direction with
<1,-1,1> (to bounce from the y-plane) and a float < 1 for
dampening, and go on until you reach the present time. Shouldn't
be too difficult.

Regards,
Tim


--
Tim Nikias
Homepage: http://www.digitaltwilight.de/no_lights/index.html
Email: Tim### [at] gmxde
"Tim Nikias" <tim### [at] gmxde> schrieb im Newsbeitrag
news:3d89870b$1@news.povray.org...
> Oops, that should be
>
> Actual_Direction_Speed = Direction_Speed - Time*Gravity*y;
>
> not plus (+) Gravity.
>
> --
> Tim Nikias
> Homepage: http://www.digitaltwilight.de/no_lights/index.html
> Email: Tim### [at] gmxde
>
>


Post a reply to this message

From: Rohan Bernett
Subject: Re: Flying and bouncing debris
Date: 29 Sep 2002 03:40:02
Message: <web.3d96ad80d26a61b2c571aa6c0@news.povray.org>
Tim: thanks for the help, it's certainly helping, but I still can't get it
to work. *sigh* Here is my code so far:
///===================
//#declare Time = clock;
#declare Time = 3.6;
#declare groundheight = 0;
#declare Gravity = 9.8; // 1.6
#declare elastic = 0.5;
#declare Actual_Position = <0,0,0>;
#declare Start_Position = <0,20,0>;
#declare Direct_Speed = <1.5,0,0>;
#declare Hit_time = 0;
#declare Actual_Direct_Speed = 0;

#declare Hit_time= -((Direct_Speed.y/Gravity)-sqrt(
pow(Direct_Speed.y/Gravity,2)+((2*Start_Position.y)/Gravity) ));
#debug "hit time="
#debug str(Hit_time,8,0)

#declare counter = 0;
#while (counter < Time)
 #declare Hit_time= -((Direct_Speed.y/Gravity)-sqrt(
pow(Direct_Speed.y/Gravity,2)+((2*Start_Position.y)/Gravity) ));

 #declare Actual_Direct_Speed = Direct_Speed - Time*Gravity*y;
 #if (counter > Hit_time)
  #declare Direct_Speed = Actual_Direct_Speed*<1,-1,1>*elastic;
 #else
  #declare Direct_Speed = Actual_Direct_Speed;
 #end
 #declare counter = counter + 0.1;
#end

#declare
Actual_Position=Start_Position+Direct_Speed*Time-y*.5*Gravity*pow(Time,2);

object{rock  translate Actual_Position} // okay, it's actually just a
sphere, for now
///=================

The two Time lines are for running the animation generation, and testing
certain points.

This is a lot harder I thought it would be. :-(

Rohan _e_ii


Post a reply to this message

From: Tim Nikias
Subject: Re: Flying and bouncing debris
Date: 29 Sep 2002 12:39:42
Message: <3d972cce@news.povray.org>
I hope this doesn't wrap...

The usage is simple:
-Declare some variables
-Place object and call macro
-Done!

It supports different sized spheres, you can set maximum
of rebounces and the minimum speed an object needs to
have for an actual rebounce, otherwise the algorithm
simplifies itself by leaving some calculations away.

I think in some formulae I mixed some + and -, was pretty
hard tracking the mistake down...

Here's the code:

//My version:

//Environmental settings:
#declare Time=clock*5;
#declare Gravity=9.8;
#declare Ground_Height=0;
#declare Ground_Friction=.9;
#declare Rebounce_Threshold=.05;
#declare Rebounce_Amount=4;

//The macro
#macro Generate_Path()
 #local _Act_DirSpeed=Object_DirSpeed;
 #local _Act_Pos=Object_Start;
 #local _Act_Timer=Time;
 #local _Stay_On_Floor=false;
 #local _Reb_Counter=0;
 //Find a hit
 #local _Hit_Time=
((_Act_DirSpeed.y/Gravity) +
 sqrt(pow(_Act_DirSpeed.y/Gravity,2) +
((2*(_Act_Pos.y-Object_Radius-Ground_Height))/Gravity) ));
 //Compare to timer...
 #while (_Hit_Time<_Act_Timer & _Hit_Time>0 & !_Stay_On_Floor)
  //Get position and speed of impact
  #local _Act_Pos= (_Act_Pos + _Act_DirSpeed*_Hit_Time -
y*.5*Gravity*pow(_Hit_Time,2))*<1,0,1> +
y*(Ground_Height+Object_Radius+.001);
  #local _Act_DirSpeed=(_Act_DirSpeed-
(y*Gravity*_Hit_Time))*<1,-1,1>*Ground_Friction;
  //Check for speed-threshold
  #if (_Act_DirSpeed.y<Rebounce_Threshold) #local _Stay_On_Floor=true; #end
  //Get remaining time
  #local _Act_Timer=_Act_Timer-_Hit_Time;
  //Generate new hit-time
  #local _Root=
pow(_Act_DirSpeed.y/Gravity,2)+((2*(_Act_Pos.y-Object_Radius-Ground_Height))
/Gravity);
  #if (_Root>0)
   #local _Hit_Time=((_Act_DirSpeed.y/Gravity)+sqrt(_Root )); #else
   #local _Hit_Time=0; #end
  #if (_Hit_Time<0) #local _Hit_Time=0; #end
  //Counting the rebounces
  #local _Reb_Counter=_Reb_Counter+1;
  #if (_Reb_Counter=Rebounce_Amount) #local _Stay_On_Floor=true; #end
 #end
 //Place on floor if required...
 #if (!_Stay_On_Floor)
  #local
_Act_Pos=_Act_Pos+_Act_DirSpeed*_Act_Timer-y*.5*Gravity*pow(_Act_Timer,2);
#else
  #local
_Act_Pos=(_Act_Pos+_Act_DirSpeed*_Act_Timer-y*.5*Gravity*pow(_Act_Timer,2))*
<1,0,1>+y*(Ground_Height+Object_Radius); #end
 //Return
 (_Act_Pos)
#end

//Generates different sized spheres
#macro Rock_Macro()
sphere{0,Object_Radius pigment{rgb x}}
#end

#declare R=seed(1);

#declare C=0;
#while (C<20)

//POV will stop with an error-message if these aren't declared PRIOR the
macro-call
#declare Object_Radius=.2+.2*rand(R); //Will also be used for the Rock-Macro
#declare
Object_Start=vnormalize(<rand(R)*2-1,rand(R)*2-1,rand(R)*2-1>)*.2+y*2;
#declare
Object_DirSpeed=vnormalize(<rand(R)*2-1,rand(R)*2-1,rand(R)*2-1>)*rand(R)*10
;

object{Rock_Macro() translate Generate_Path()}

#declare C=C+1;
#end

Hope this helps,

Tim


--
Tim Nikias
Homepage: http://www.digitaltwilight.de/no_lights/index.html
Email: Tim### [at] gmxde


Post a reply to this message

<<< Previous 2 Messages Goto Initial 10 Messages

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.