using physics in javascript