I wanted to make an animation for simple harmonic motion.  I used the sin function.  It worked great.

I then wanted to make an animation showing a ball bouncing in a box.  The sin wave motion did not look correct.  I needed a saw tooth wave.  No saw tooth function exists.

I did a simple Fourier analysis.  I found an approximated sawtooth wave could be had by.

wave sawtooth = .95 sin t - .5 sin 3t

It looks better.

here is the link that shows the two motions.  Can you see the difference?

Chapter 7

here is the script that gets embedded into the HTML


<SCRIPT language="JScript">
count2=0;
function onInterval2() {
                   with(document.body)
{
             
if(clientWidth>200)
           {
{imagefly2.style.left= 81*( .95*Math.sin(count2) - .05*Math.sin(3*count2))+ (clientWidth -305);}

imagefly2.style.top=158;
                                         count2=count2+.07;

if(count2>4300)
{count2 = 0;}




               }
}
}



writeRetrun("");

setInterval("imagefly2.style.display='';onInterval2();",30);

                   function writeRetrun(displaySetting) {

var frmSnip=' style="POSITION:Relative;background-color:none;top:0;left:'+0;
document.writeln('<DIV align=left id=imagefly2'+frmSnip+'display:none;visibility:visible;"><IMG SRC="" border=0 USEMAP="" name=sticky_map><area coords=95,0,130,158 href="" ></map></DIV>');

                                                                                  }



</SCRIPT>


enjoy

Frank Znidarsic

Reply via email to