{"id":4997,"date":"2020-09-14T03:12:03","date_gmt":"2020-09-14T07:12:03","guid":{"rendered":"https:\/\/courses.ideate.cmu.edu\/60-212\/f2020\/?page_id=4997"},"modified":"2020-09-14T03:43:44","modified_gmt":"2020-09-14T07:43:44","slug":"springs","status":"publish","type":"page","link":"https:\/\/courses.ideate.cmu.edu\/60-212\/f2020\/daily-notes\/september\/09-14-movement\/springs\/","title":{"rendered":"Springs"},"content":{"rendered":"<p><strong>The universe can be modeled from springs.<\/strong> Nearly every solid material can be thought of as a collection of particles which are attached to each other by elastic forces.<\/p>\n<p>From Isaac Newton (1686), we know his second <a href=\"https:\/\/en.wikipedia.org\/wiki\/Newton%27s_laws_of_motion\" target=\"_blank\" rel=\"noopener noreferrer\">law of motion<\/a>, that\u00a0<em><strong>F = ma<\/strong><\/em>.<br \/>\nThis states that in general, force is proportional to mass times acceleration.<\/p>\n<p>From Robert Hooke (1678), we know the <a href=\"https:\/\/en.wikipedia.org\/wiki\/Hooke%27s_law\" target=\"_blank\" rel=\"noopener noreferrer\">spring law<\/a>,\u00a0<strong><em>F = -Kx<\/em><\/strong>.<br \/>\nThis states that the force applied by a spring, is proportional (by some constant\u00a0<em><strong>K<\/strong><\/em>) to its distention\u00a0<em><strong>x<\/strong>\u00a0<\/em>(amount of stretch or compression). The minus sign tells us that the spring\u2019s \u201crestorative force\u201d happens in the opposite direction.<\/p>\n<p>To take an example, if you stretch a spring (which is rigidly fixed at one end) one centimeter to the east, it will apply a restoring force towards the west. If you stretch it\u00a0<em>two<\/em>\u00a0centimeters eastward, it will apply a westerly force which is twice as strong.<\/p>\n<p>Because\u00a0<em><strong>F = ma<\/strong><\/em>\u00a0and\u00a0<em><strong>F = -kx<\/strong><\/em>, we can derive\u00a0that\u00a0<strong><em>ma = -kx<\/em><\/strong>. Interestingly, this\u00a0is actually a \u201csecond-order differential equation\u201d \u2014 which describes a relationship between\u00a0a particle\u2019s position,\u00a0<em><strong>x<\/strong><\/em>, \u00a0and its acceleration (or the\u00a0rate of change of the\u00a0rate of change of its position),\u00a0<em><strong>a<\/strong><\/em>. The solution to such equations always take the form of an \u201cexponentially damped cosinusoid\u201d, in what is called\u00a0<em>damped harmonic motion<\/em>:<\/p>\n<p><a href=\"https:\/\/courses.ideate.cmu.edu\/60-212\/f2020\/wp-content\/uploads\/2020\/09\/3c_41.png\"><img loading=\"lazy\" class=\"alignnone size-full wp-image-5004\" src=\"https:\/\/courses.ideate.cmu.edu\/60-212\/f2020\/wp-content\/uploads\/2020\/09\/3c_41.png\" alt=\"\" width=\"286\" height=\"167\" \/><\/a><\/p>\n<p>Pleasingly, this exactly captures\u00a0the movement of a spring over time: it wiggles back and forth, gradually losing energy due to friction. Depending on the amount of damping, the spring may be very wiggly, or not. We use terms like\u00a0<em>overdamped<\/em>\u00a0and\u00a0<em>underdamped<\/em>\u00a0to describe this:<\/p>\n<p><a href=\"https:\/\/courses.ideate.cmu.edu\/60-212\/f2020\/wp-content\/uploads\/2020\/09\/Fig-10-33.gif\"><img loading=\"lazy\" class=\"alignnone size-full wp-image-5005\" src=\"https:\/\/courses.ideate.cmu.edu\/60-212\/f2020\/wp-content\/uploads\/2020\/09\/Fig-10-33.gif\" alt=\"\" width=\"404\" height=\"246\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>The constant\u00a0<em><strong>K<\/strong><\/em>\u00a0is the \u201cspring constant\u201d which is unique for each material. When the value of\u00a0<strong><em>K<\/em><\/strong>\u00a0is high, the material is stiff, snappy or brittle. When K is low, the material is soft, flexible, stretchy. (<em>High values of K will expose the limits of Euler integration, our current numerical method for solving springs here; if K is too high, the simulation will \u201cexplode\u201d. We\u2019ll let you discover that\u2026<\/em>). You can find the value of K in the code samples below. Good values for our solver are in the range of 0.01 to 0.5; try using 0.1 to get started.<\/p>\n<p>There is also a\u00a0<strong>damping<\/strong>\u00a0factor in our particles which describes how much energy they retain after\u00a0each frame of animation. A value of 0.96 is fine to get started (meaning, they lose 4% of their energy each frame). Under no circumstances should you ever set this higher than 1.0! Lower values (e.g. 0.7, 0.5, etc.) will cause overdamping.<\/p>\n<hr \/>\n<h3>Springs 1 (Simple)<\/h3>\n<p>Here, two particles are connected to each other by a spring. Pulling one away from the other, causes the spring to exert an elastic restorative force on each.<br \/>\n<a href=\"https:\/\/editor.p5js.org\/golan\/sketches\/igR5OYolp\">springs-simple.js<\/a><\/p>\n<p>When particles are connected by rigid elements in a triangle, we have the fundamental element of truss structures. All architects know this. (The following simulation also has a gravity force added in to the particles, so that they are affected both by gravity and by spring forces.)<br \/>\n<a href=\"https:\/\/editor.p5js.org\/golan\/sketches\/T2rYvLsfn\">springs-triangle.js<\/a><\/p>\n<p>It\u2019s possible to \u201cfix\u201d one or more particles to a rigid location. It is as if one particle were attached to something too large to move:<br \/>\n<a href=\"https:\/\/editor.p5js.org\/golan\/sketches\/2uBF6dPVL\">springs-fixed.js<\/a><\/p>\n<h3>Springs 2 (Rope, with and without Gravity)<\/h3>\n<p>We can connect multiple particles into a rope. A for() loop has been used to connect each particle to the next one. Here we see the basic code structure we will be using: an array of particles, and an array of springs which (selectively) connects certain ones among them:<br \/>\n<a href=\"https:\/\/editor.p5js.org\/golan\/sketches\/PcCme3hJq\">springs-rope.js<\/a><\/p>\n<p>Here is the same example, but with a gravity force added in. Architects will readily recognize that the simulation is able to achieve the well-known catenary curve.<br \/>\n<a href=\"https:\/\/editor.p5js.org\/golan\/sketches\/1cv-njqyQ\">springs-rope-gravity.js<\/a><\/p>\n<h3>Springs 3 (Blob)<\/h3>\n<p>In this example, particles are placed around the perimeter of a circle. Then springs are used to connect each one to its neighbor. All of particles are also connected by a spring to a single central particle, like spokes of a wheel. I have taken the liberty of decorating this set of particles with a closed Bezier curve that stitches through them all:<br \/>\n<a href=\"https:\/\/editor.p5js.org\/golan\/sketches\/wa0sn5fNZ\">springs-wheel.js<\/a><\/p>\n<p>In this example, particles are placed around the perimeter of a circle. Then springs are used to connect (some of) them. Specifically, particles are connected to their neighbors, and some of their other nearby neighbors as well. The result is a kind of bouncy bag:<br \/>\n<a href=\"https:\/\/editor.p5js.org\/golan\/sketches\/tN09_szTo\">springs-blob.js<\/a><\/p>\n<h3>Springs 4 (Big Square Mesh)<\/h3>\n<p>Here is a classic mesh. Just as in real life, for proper rigidity, we have to connect elements diagonally, or else the structure will not have integrity and will collapse. The code for doing so is (slightly) tricky.<br \/>\n<a href=\"https:\/\/editor.p5js.org\/golan\/sketches\/-XAvixBhM\">springs-mesh1.js<\/a><\/p>\n<h3>Springs 5 (Auto-Bouncy Mesh)<\/h3>\n<p>We can grab one of the particles and move it automatically. Here one particle is being moved by a combination of sinusoidal and Perlin-noise forces. The rest of the mesh accommodates. (Note that this example is not interactive.)<br \/>\n<a href=\"https:\/\/editor.p5js.org\/golan\/sketches\/Pg1nwWoTb\">springs-mesh2<\/a><\/p>\n<h3>Springs 6 (Narrow Truss)<\/h3>\n<p>Here is a narrow truss which imitates a bottom-feeding worm:<br \/>\n<a href=\"https:\/\/editor.p5js.org\/golan\/sketches\/7nwO0B5uk\">springs-truss.js<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>The universe can be modeled from springs. Nearly every solid material can be thought of as a collection of particles which are attached to each other by elastic forces. From Isaac Newton (1686), we know his second law of motion, that\u00a0F = ma. This states that in general, force is proportional to mass times acceleration. &hellip; <a href=\"https:\/\/courses.ideate.cmu.edu\/60-212\/f2020\/daily-notes\/september\/09-14-movement\/springs\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Springs&#8221;<\/span><\/a><\/p>\n","protected":false},"author":3,"featured_media":0,"parent":4941,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":[],"_links":{"self":[{"href":"https:\/\/courses.ideate.cmu.edu\/60-212\/f2020\/wp-json\/wp\/v2\/pages\/4997"}],"collection":[{"href":"https:\/\/courses.ideate.cmu.edu\/60-212\/f2020\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/courses.ideate.cmu.edu\/60-212\/f2020\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/60-212\/f2020\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/60-212\/f2020\/wp-json\/wp\/v2\/comments?post=4997"}],"version-history":[{"count":5,"href":"https:\/\/courses.ideate.cmu.edu\/60-212\/f2020\/wp-json\/wp\/v2\/pages\/4997\/revisions"}],"predecessor-version":[{"id":5006,"href":"https:\/\/courses.ideate.cmu.edu\/60-212\/f2020\/wp-json\/wp\/v2\/pages\/4997\/revisions\/5006"}],"up":[{"embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/60-212\/f2020\/wp-json\/wp\/v2\/pages\/4941"}],"wp:attachment":[{"href":"https:\/\/courses.ideate.cmu.edu\/60-212\/f2020\/wp-json\/wp\/v2\/media?parent=4997"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}