I believe the problem is because you are not using sin, cos, and tan properly. You are using those labels as temporary variables as shown here:
sin = math.sin(sim.time);
cos = math.cos(sim.time);
tan = math.tan(sim.time);
Sin is equivalent to math.sin(), and the same for cos and tan. Because of that, they must not be used as variables (like you did). So, simply choose some other variables such as _sin, _cos, and _tan. Make sure to first define those variables by using "onSpawn". You can initialize them with zero like this:
Caution: sin, cos, and tan will no longer work properly because your script permanently changed them when you used them as variables instead of functions. Because of that you need to RESET Algodoo. I had to do that for my Algodoo app after running your scene! Click on the little white gear next to "File" in the upper left corner, then select RESET and follow the simple instructions. Your scene should work after making those changes. Of course you will need to re-upload your scene. Then test it by downloading it from Algobox to make sure that it works as expected.