# Bouncing spring

• Sharebar

Bouncing is fun. A spring has potential (elastic?) energy that has many uses in our life. Can you think of any uses? I just had a front suspesion replace in my old car. There are two big springs (or perhaps 4, I did not check back wheels) on top of the two front wheels. The two springs make sitting in the car comfortable by obsorbing forces and only bouncing slightly when driving (on rocky road).

This is the first attemp to create a 3D spring. I used line only and with the easy movement of the turtle, it is quite easy to create one. This spring will bounce forever if you don't over stretch it. :-)

Below is the Logo program I wrote to create this spring. Have a look and I will explain later.

The spring is created from line 6 to line 10. A total of 200 repeats to make the turtle "roll up a bit, forward a bit (10 cm), roll down a bit, then turn right a bit". So my new definition (meaning) for a spring is now "roll up a bit, forward a bit (10 cm), roll down a bit, then turn right a bit". When I say "a bit", you know it is about the 10 degress and the 10 cms. I have the following questions for you to figure out:

• What if you ask the turtle to turn less degrees or more degrees?
• What if you ask the turtle to forward less or more centimetres?
• What should I change if I want a wider or narrower spring?
• What if I use different combination of 3D rotations such as TILTRIGHT and LEFT?

From line 12 to line 18, the codes make the spring bounces. The idea is to change the scale of this spring's Y dimension so to create the bouncing effect. As can be seen, the scale (:value) changed from [1 1 1] to [1 .2 1] then back to [1 1 1] during the time fraction of [0 .7 1]. This means that from 0 to 0.7 of the whole (1) cycle, the Y scale will animate from 1 to 0.2, and then from 0.7 to 1 of the whole cycle, the Y scale will change from 0.2 back to 1. The whole animation will complete in 1.5 second cycle, and loops continuously.  The setting of the :key will create an effect, in which the spring compress slower and bounce back faster. To this, I also have some questions for you to think about:

• How exactly should the spring behave when you press it and let go?
• In the above program, I only used three time frames [0 0.7 1] with three different Y scales. It may animate quite like a real spring, but what can you do to make it go faster or slower or bounce a couple more in each cycle?

Please feel free to play with the program in VRMath2 Editor. You can copy and paste the codes from this blog or simply open the Logo program in the logo - > animation folder in the Example space.