POV-Ray : Newsgroups : povray.animations : Help with SDL for Bouncing Ball Server Time: 16 Dec 2018 01:33:16 GMT
  Help with SDL for Bouncing Ball (Message 1 to 10 of 14)  
Goto Latest 10 Messages Next 4 Messages >>>
From: Bald Eagle
Subject: Help with SDL for Bouncing Ball
Date: 27 Dec 2016 22:35:00
Message: <web.5862ebe4a2841af780403a200@news.povray.org>
The subject of creating a "simple" animation of a bouncing ball recently came
up, and as I looked into it, and considered how to do this, it is apparently
less simple than I thought it would be.

I would imagine that a critical factor in making the animation work out well
would be to find the total time for the ball to (practically) come to rest, and
then define the number of frames in the animation based on that.

Perhaps then one could work out the time per fall/bounce, the heights,
velocities, positions, etc. in a fairly straightforward manner.

I think for a good animation, there would need to be a good way to handle the
squashing of the ball and the deceleration prior to restoring the ball to a
sphere and resuming the bouncing cycle.
Probably define a percentage squash factor and use that times the radius to
establish the 'zero' height point.

I searched around for a good thread, because I figured that surely someone had
done something so basic - but there were no example scenes that I found, and
most people were using particle systems of some sort to make more complicated /
more general animations.

I was wondering if anyone had any practical and concrete advice on how to handle
the various parts of the animation, and how to organize the code in a sensible
manner.

I'm traveling and juggling a lot of metaphorical balls at the moment, so it may
not be until next week that a get a chance to sit down, gather my wits about me,
and hammer out some semi-functional SDL, but at least I was hoping to read some
comments advice, and code snippets that would set me on the right track from the
start.


Thanks!   :)


Post a reply to this message

From: Le Forgeron
Subject: Re: Help with SDL for Bouncing Ball
Date: 27 Dec 2016 22:53:23
Message: <5862f0e3$1@news.povray.org>
Le 27/12/2016 à 23:32, Bald Eagle a écrit :
> The subject of creating a "simple" animation of a bouncing ball recently came
> up, and as I looked into it, and considered how to do this, it is apparently
> less simple than I thought it would be.
> 
> I would imagine that a critical factor in making the animation work out well
> would be to find the total time for the ball to (practically) come to rest, and
> then define the number of frames in the animation based on that.
> 
> Perhaps then one could work out the time per fall/bounce, the heights,
> velocities, positions, etc. in a fairly straightforward manner.
> 
> I think for a good animation, there would need to be a good way to handle the
> squashing of the ball and the deceleration prior to restoring the ball to a
> sphere and resuming the bouncing cycle.
> Probably define a percentage squash factor and use that times the radius to
> establish the 'zero' height point.
> 
> I searched around for a good thread, because I figured that surely someone had
> done something so basic - but there were no example scenes that I found, and
> most people were using particle systems of some sort to make more complicated /
> more general animations.
> 
> I was wondering if anyone had any practical and concrete advice on how to handle
> the various parts of the animation, and how to organize the code in a sensible
> manner.
> 
> I'm traveling and juggling a lot of metaphorical balls at the moment, so it may
> not be until next week that a get a chance to sit down, gather my wits about me,
> and hammer out some semi-functional SDL, but at least I was hoping to read some
> comments advice, and code snippets that would set me on the right track from the
> start.
> 
> 
> Thanks!   :)
> 
> 

Does the ball really need to be seen deformed ? Can you consider a
billiard (pool) ball, or a bowling ball ?

Rule of animation & cartoon: when cutting a tree with an axe, do not
bother with the frame on which the axe meet the tree.

There was a bouncing ball in the scene of povray: boing , but you will
need any of 3.1 up to 3.6.1 version (of particular interest
scenes/animation/boing/bounce.pov )


Post a reply to this message

From: Bald Eagle
Subject: Re: Help with SDL for Bouncing Ball
Date: 27 Dec 2016 23:20:00
Message: <web.5862f651ccfba4d980403a200@news.povray.org>
Le_Forgeron <jgr### [at] freefr> wrote:

> Does the ball really need to be seen deformed ? Can you consider a
> billiard (pool) ball, or a bowling ball ?

No, of course not - a preliminary version could use a perfectly elastic
collision with a non-deforming sphere, but I think that the deformation would
look nice, especially at close range and slow speeds

> Rule of animation & cartoon: when cutting a tree with an axe, do not
> bother with the frame on which the axe meet the tree.

OK - good to know - That was certainly a concern of mine.   I suppose that might
greatly simplify the task and shorten the number of frames required.

> There was a bouncing ball in the scene of povray: boing , but you will
> need any of 3.1 up to 3.6.1 version (of particular interest
> scenes/animation/boing/bounce.pov )

Thank you very much for that!  :)
Admittedly, I often forget to look in the /scenes subdirectories where there are
samples scenes, but as it's not there anyway, I found a copy here:
http://code.metager.de/source/xref/povray/3.6.1/scenes/animations/boing/boing1.pov

I'll give it a look over and see what I can work out.

(It's always a joy to have so many POV-Ray experts available who in turn have so
much experience and so many references and resources readily available)


Post a reply to this message

From: omniverse
Subject: Re: Help with SDL for Bouncing Ball
Date: 28 Dec 2016 03:05:00
Message: <web.58632b84ccfba4d99c5d6c810@news.povray.org>
"Bald Eagle" <cre### [at] netscapenet> wrote:
> Le_Forgeron <jgr### [at] freefr> wrote:
>
> > Does the ball really need to be seen deformed ? Can you consider a
> > billiard (pool) ball, or a bowling ball ?
>
> No, of course not - a preliminary version could use a perfectly elastic
> collision with a non-deforming sphere, but I think that the deformation would
> look nice, especially at close range and slow speeds
>
> > Rule of animation & cartoon: when cutting a tree with an axe, do not
> > bother with the frame on which the axe meet the tree.
>
> OK - good to know - That was certainly a concern of mine.   I suppose that might
> greatly simplify the task and shorten the number of frames required.
>
> > There was a bouncing ball in the scene of povray: boing , but you will
> > need any of 3.1 up to 3.6.1 version (of particular interest
> > scenes/animation/boing/bounce.pov )
>
> Thank you very much for that!  :)
> Admittedly, I often forget to look in the /scenes subdirectories where there are
> samples scenes, but as it's not there anyway, I found a copy here:
> http://code.metager.de/source/xref/povray/3.6.1/scenes/animations/boing/boing1.pov

With 3.5 I had installed here, didn't know it wasn't part of 3.7 anymore.

Had to try something with it myself so I used brute force. Probably a bad way to
go about it. Only for 150 frames, beginning at 0 and going to 149; I also used
Cyclic_Animation=on so it would be repeatable.

sphere { 0, 10
 #if(frame_number<2)
scale <1+0.1,1-0.1,1+0.1> #end
 #if(frame_number>36&frame_number<38)
scale <1-clock/3,1+clock/3,1-clock/3> #end
 #if(frame_number>74&frame_number<77)
scale <1+clock/5,1-clock/5,1+clock/5> #end
 #if(frame_number>111&frame_number<113)
scale <1-0.1,1+0.1,1-0.1> #end
 #if(frame_number>=149)
scale <1+0.1,1-0.1,1+0.1> #end
texture{...}
    translate <spherex,spherey, 0>
}

Simply deforms the sphere a frame or two where I found the floor and wall hits
to be, but delayed a frame to look more like a reaction. Not exact, by all
means.
Failed on the final frame, I guess because cyclic drop s a frame. Made it
squeeze before hitting floor. Doesn't seem to matter for the start.

To me the 150 frames is already a slow motion look but when trying shorter
animation the instance at wall/floor hit can get missed.


#default{pigment{blue 1}}#for(I,-1,1,1)
#if(I!=0)cylinder{<I-.3,0,3>,<I-.3,1,3>,.2}#end
sphere{<I-.1,0,3>,.4}#end//bob


Post a reply to this message

From: dick balaska
Subject: Re: Help with SDL for Bouncing Ball
Date: 28 Dec 2016 06:57:45
Message: <58636269$1@news.povray.org>
Am 2016-12-27 17:32, also sprach Bald Eagle:

> I was wondering if anyone had any practical and concrete advice on how to handle
> the various parts of the animation, and how to organize the code in a sensible
> manner.

A plug for my "movie": http://www.buckosoft.com/tteoac/

I use basic physics for my sphere's motion.  Each sphere has a position 
and a vector. The vector is updated based on gravity and added to the 
position.  Then the position is tested for bouncing and the vector 
modified. (I sort of squish my volcano (cone) before it erupts. ;) )
To squish spheres, I would add a squishFactor = 0; and squishMax = r/2;
   if (sphere.y - r < 0) squishAccelerate = 0.5;
Then iterate,
   squishAccelerate gets added to squishFactor,
   squishAccelerate gets updated, while squishing decrement towards 0
   sphere gets drawn as r - squishFactor.

Hmm, I may have to see what squishing looks like on my spew. :)
My bouncing code is here http://tinyurl.com/jcg8g4s [1]
but it won't help you because it's Java. Once I started testing 1500 
spheres bouncing off of each other I was looking at 24 hour parse times 
in povray, so I moved that off to Java which spits out povray source 
like this. http://tinyurl.com/zk9d9t5 [2]

I break down every move so that at it's fundamental, every move runs 
from 0.0-1.0, so normal sphere (0.0) would be squishFactor = 0 and 
squished (1.0) would be squishFactor = r/2;

But you can't run squishFactor linearly from 0.0-1.0, that looks too 
robotic.  I apply an acceleration curve like Curve0 on this page.
http://www.buckosoft.com/~dick/pov/curves/
So while my timer runs 0.0-1.0, squishFactor is massaged by that quarter 
cosine.

This is all probably way more complicated than you want, ;)
but that's how I do it.

-- 
dik

[1] alias for 
http://git.buckosoft.com/gitweb/pov.cgi?p=TteoacService.git;a=blob;f=src/main/java/com/buckosoft/povspew/tteoac/Volcano/VolcanoRunner.java;h=3ec758b0504ad201ecbd847dc695dfe30927fc7e;hb=HEAD

[2] alias for 
http://www.buckosoft.com/tteoac/tteoac/service?scene=tteo|fps=23.976|type=Volcano|frame=1900


Post a reply to this message

From: clipka
Subject: Re: Help with SDL for Bouncing Ball
Date: 28 Dec 2016 07:11:49
Message: <586365b5@news.povray.org>
Am 27.12.2016 um 23:32 schrieb Bald Eagle:
> The subject of creating a "simple" animation of a bouncing ball recently came
> up, and as I looked into it, and considered how to do this, it is apparently
> less simple than I thought it would be.

... or maybe you're currently seeing more complications than there are ;)

> I would imagine that a critical factor in making the animation work out well
> would be to find the total time for the ball to (practically) come to rest, and
> then define the number of frames in the animation based on that.

The problem there is that there is no single true answer; the solution
is that there is a host of them, and you can freely choose one.

The time the ball remains in contact with the surface essentially
depends on one single parameter: The combined ball's and surface's
resistance to being deformed. You can express this as a force, which for
simplicity's sake you can pretend as being roughly proportional to the
distance by which the ball has already moved beyond the point of
contact, and this force will counteract gravity. To work out the
equation for the ball's movement shouldn't be much more difficult than
working out the equation for a ball in free flight, except that this
time you have a cubic rather than quadratic equation.

If you're going for the simple hack of just keeping the ball stationary
for a few moments anyway, you can essentially choose any time you like,
so long as you don't violate fundamental physical limits (a ball so
easily deformable that it would sink in by more than its own diameter
doesn't make much sense ;))


Post a reply to this message

From: Bald Eagle
Subject: Re: Help with SDL for Bouncing Ball
Date: 3 Jan 2017 17:40:01
Message: <web.586be1bfccfba4d9c437ac910@news.povray.org>
I was just checking out some further stuff on this and found:

http://scienceblogs.com/startswithabang/files/2012/09/PWjWR.gif

Wowza.  :O
That looks like a cool spherical harmonic isosurface to model!   ;)

from:
http://scienceblogs.com/startswithabang/2012/09/15/weekend-diversion-the-physics-of-happy-gilmore/


Post a reply to this message

From: omniverse
Subject: Re: Help with SDL for Bouncing Ball
Date: 4 Jan 2017 13:15:00
Message: <web.586cf4b2ccfba4d99c5d6c810@news.povray.org>
"Bald Eagle" <cre### [at] netscapenet> wrote:
> I was just checking out some further stuff on this and found:
>
> http://scienceblogs.com/startswithabang/files/2012/09/PWjWR.gif
>
> Wowza.  :O
> That looks like a cool spherical harmonic isosurface to model!   ;)
>
> from:
>
http://scienceblogs.com/startswithabang/2012/09/15/weekend-diversion-the-physics-of-happy-gilmore/

Heck, I knew a golf club bends a little and ball would deform slightly but sure
didn't realize it was like that.
The 50 pound plate hit makes the ball look unreal. In fact, I can hardly believe
it isn't bursting apart instead of flattening out, and then able to reshape like
a soft-boiled egg.

Once when a teenager I peeled a golf ball down to a small inner rubber core
(liquid-filled? I forget), lots of rubbery strands between the hard plastic
shell and that. Just never thought of the shell itself as being pliable enough
to stretch so much.


Post a reply to this message

From: Stephen
Subject: Re: Help with SDL for Bouncing Ball
Date: 4 Jan 2017 13:34:42
Message: <586cf9f2@news.povray.org>
On 1/4/2017 1:12 PM, omniverse wrote:

>
> Once when a teenager I peeled a golf ball down to a small inner rubber core
> (liquid-filled? I forget), lots of rubbery strands between the hard plastic
> shell and that. Just never thought of the shell itself as being pliable enough
> to stretch so much.
>
>
>
I think you are showing your age. :-P
At least it wasn't filled with feathers. :-)

If I remember correctly, my grandfather ;-) told me it was a white paint 
like liquid.

-- 

Regards
     Stephen


Post a reply to this message

From: Stephen
Subject: Re: Help with SDL for Bouncing Ball
Date: 5 Jan 2017 13:48:13
Message: <586e4e9d$1@news.povray.org>
On 12/27/2016 10:32 PM, Bald Eagle wrote:
> I think for a good animation, there would need to be a good way to handle the
> squashing of the ball and the deceleration prior to restoring the ball to a
> sphere and resuming the bouncing cycle.


I don't know if this will be of any use. It has equations in it, though. :-)

http://www.beosil.com/download/MeshlessDeformations_SIG05.pdf

I have just started to use Blender's Bullet Physics and came across this.


-- 

Regards
     Stephen


Post a reply to this message

Goto Latest 10 Messages Next 4 Messages >>>

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