Code covered by the BSD License  

Highlights from
Bouncing Smiley Face

5.0

5.0 | 4 ratings Rate this file 11 Downloads (last 30 days) File Size: 5.45 KB File ID: #23081
image thumbnail

Bouncing Smiley Face

by Husam Aldahiyat

 

23 Feb 2009 (Updated 25 Feb 2009)

Exaggerated and somewhat cartoonish simulation of the physics of a bouncing smiley face.

| Watch this File

File Information
Description

The laws for rotation are probably wrong (I made them up actually), but that's not what this file is about. Shown here is a very simple code that creates a nice animation, which can be quickly edited to suit anyone's needs.

The parameters are ball radius, gravity, initial velocity in the Y direction, initial velocity in the X direction, vertical speed conservation (%), horizontal speed conservation (%) and initial angular velocity.

Please note that the ball may stop moving at different locations for different trials, even with the same input parameters. This is due to the slight randomization of the deformations of the ball and the ground, which could lead to the ball getting "stuck" to the ground at times and stopping there. This is normal and deliberate.

Set the vertical speed conservation as a value larger than 100 (e.g. 130) for a small bonus ;)

Acknowledgements

The author wishes to acknowledge the following in the creation of this submission:
Bouncing Ball Physics

MATLAB release MATLAB 7.4 (R2007a)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (8)
24 Feb 2009 John D'Errico

Looks very nice. I was disappointed that no mention was made of the requirements for use. NO image processing toolbox, no go.

??? Undefined function or method 'imrotate' for input arguments of type 'uint8'.

Error in ==> bb2>go at 282
   iii=image(imrotate(uint8(flipud(am)),ll,'bilinear','crop'),'xdata',[ccc2-r/2,ccc2+r/2],'ydata',[ccc-r/2
         ccc+r/2]);

??? Error while evaluating uicontrol Callback

24 Feb 2009 Husam Aldahiyat

Ah, sorry about that. Will send an update that brings notice to this. Also, you're to be mentioned as inspiration in the code. Forgot to include that in before.

As for getting around the problem, I don't think there's a simple way to do it, so anyone without the Image Processing Toolbox should comment out lines 278 and 282. The result is missing out on the smiley face bit altogether.

24 Feb 2009 Kenneth Eaton

One solution to the dependence on the Image Processing Toolbox... you could plot a square surface object, then texture map the smiley-face image onto it. Then you can simply rotate the surface object yourself, without a need for the IPT.

25 Feb 2009 Husam Aldahiyat

Wow, too easy. Thanks.

25 Feb 2009 John D'Errico

The appropriate review would just be this.

8-)

24 Mar 2009 NOUR  
29 Apr 2009 David

Great program.

07 Feb 2010 Amelia

Yes, great program Husam!

Please login to add a comment or rating.
Updates
23 Feb 2009

Fixed eccentricity error, horizontal conservation error.

25 Feb 2009

Code now works on systems without the Image Processing Toolbox.

Tag Activity for this File
Tag Applied By Date/Time
bouncing Husam Aldahiyat 23 Feb 2009 13:32:17
smiley Husam Aldahiyat 23 Feb 2009 13:32:17
face Husam Aldahiyat 23 Feb 2009 13:32:17
physics Husam Aldahiyat 23 Feb 2009 13:32:17
rand Husam Aldahiyat 23 Feb 2009 13:32:17
random Husam Aldahiyat 23 Feb 2009 13:32:17
image Husam Aldahiyat 23 Feb 2009 13:32:17
bouncing yasar 12 May 2010 18:22:50
ball Husam Aldahiyat 29 Nov 2010 05:59:14
circle Husam Aldahiyat 29 Nov 2010 05:59:14
gui Husam Aldahiyat 29 Nov 2010 05:59:14
gravity Husam Aldahiyat 29 Nov 2010 05:59:14
ball Thomas 07 Jan 2012 13:06:24

Contact us at files@mathworks.com