summaryrefslogtreecommitdiff
path: root/2d/softbody/softbody_1.html.content
diff options
context:
space:
mode:
authormattkae <mattkae@protonmail.com>2022-02-26 20:08:53 -0500
committermattkae <mattkae@protonmail.com>2022-02-26 20:08:53 -0500
commit38d89c1182a61ca4e024e0834ae9187db76c67f8 (patch)
treeeeb0cdabac28a0eed05d090c85028933a4645c7a /2d/softbody/softbody_1.html.content
parent8d4c5116719825dce6222c494cd384fe1df775de (diff)
Fixing spring simulations and some write ups
Diffstat (limited to '2d/softbody/softbody_1.html.content')
-rw-r--r--2d/softbody/softbody_1.html.content87
1 files changed, 76 insertions, 11 deletions
diff --git a/2d/softbody/softbody_1.html.content b/2d/softbody/softbody_1.html.content
index 602d0a8..8314bbf 100644
--- a/2d/softbody/softbody_1.html.content
+++ b/2d/softbody/softbody_1.html.content
@@ -131,17 +131,54 @@
<section>
<p>
It is time to investigate what it means to have a deformation in our physics system. By deformation, I mean that the
- vertices of our shapes are no longer fixed to one point within the model. We will begin with what I believe
- by investigating the most common of all deformations: a weight attached to a spring in two dimensions.
+ vertices of our shapes are no longer fixed to one point within the model. Towards this end, we will begin by investigating
+ springs.
</p>
</section>
<section>
- <h2></h2>
+ <h2>Undamped Spring Explanation</h2>
+ <p>
+ An <b>undamped spring</b> is one that never stops oscillating. Once an undamped spring starts moving back and forth,
+ it moves back and forth forever.
+ </p>
+ <p>
+ From Newton's second law, we know that the sum of all the forces acting on an object will equal zero. We know that one
+ of these forces is mass times acceleration, but for a spring we will add another force which uses the <i>spring constant</i>.
+ This force grows in proportion to the displacment that spring is currently set at. So, if the spring is currently displaced
+ 10m, the effect of this force will be greater than if the spring was at <i>equlibrium</i>, which means that it is displaced by
+ 0m. This should make sense intuitively.
+ </p>
+ <p>
+ One thing to note is that a damped spring has three cases:
+ <ul>
+ <li><b>Overdamped</b>: the spring will decompress immediately to the equlibrium position</li>
+ <li><b>Underdamped</b>: the spring will do one oscillation before returning to the equlibrium position</li>
+ <li><b>Critically damped: the spring will oscilate, but each oscillation will bring it closer and closer to the equlibrium position</b></li>
+ </ul>
+ I will not go into the mathematical details as to why this happens, as the links at the end of this video can very easily tell you. Just know
+ that they are dependent on your values of <i>c</i> and <i>k</i>, so choose wisely for your use case.
+ </p>
+ <p>
+ The equation is given as such:
+ <div class="formula">
+ <math class="formula">
+ ma + kx = 0
+ </math>
+ </div>
+ where <i>m</i> is the mass, <i>a</i> is acceleration, <i>k</i> is the spring constant, and <i>x</i> is the current displacement
+ from the rest position.
+ </p>
+ <p>
+ We can define an undamped 1D spring in code like so:
+ #SNIPPET softbody_1/snippet1.cpp
+
+ Note that we are just using Euler Integration here.
+ </p>
</section>
<section>
- <h2>
- Undamped Springs
- </h2>
+ <h2>
+ Undamped Springs Example
+ </h2>
<p>
<span class='widget_container'>
<label for='undamped_spring_length'>Spring Length (m)</label>
@@ -180,8 +217,39 @@
</section>
<section>
+ <h2>Damped Spring Explanation</h2>
+ <p>
+ Undamped springs are loads of fun, but if we want to make a softbody physics system, we're going to want
+ our simulation to stop oscillating at some point. That is where the <b>viscous damping constant</b> (<i>c</i>) force
+ comes in. The damping force grows in proportion to the velocity. The equation is given as such:
+
+ <div class="formula">
+ <math class="formula">
+ ma + cv + kx = 0
+ </math>
+ </div>
+
+ where <i>m</i> is the mass, <i>a</i> is acceleration, <i>c</i> is the damping constant, <i>v</i> is the velocity
+ <i>k</i> is the spring constant, and <i>x</i> is the current displacement from the rest position.
+ </p>
+ <p>
+ This force produces the most effect when the velocity is largest. Let's try to intuit exactly what this means. When
+ our spring is extended downward, it will want to move upward to return to its equlibrium position. At this point,
+ the displacement (<i>x</i>) will be negative and the velocity (<i>v</i>) will be positive. Since the signs are different,
+ we can see that our spring force will be mitigated by the damping force. Hence, we damp!
+ </p>
+
+ <p>
+ We can define a damped 1D spring in code like so:
+ #SNIPPET softbody_1/snippet2.cpp
+
+ Note that we are just using Euler Integration here.
+ </p>
+ </section>
+
+ <section>
<h2>
- Damped Springs
+ Damped Springs Example
</h2>
<p>
<span class='widget_container'>
@@ -204,7 +272,7 @@
<span class='widget_container'>
<label for='damped_viscous_constant'>Viscous Damping Constant (N / m)</label>
- <input type='range' id='damped_viscous_constant' min='0' max='1000.0' value='1.0' step='0.1'/>
+ <input type='range' id='damped_viscous_constant' min='0' max='100.0' value='1.0' step='0.1'/>
<span></span>
</span>
@@ -238,9 +306,6 @@
<li>
<a href='http://ambrsoft.com/CalcPhysics/Spring/SpringData.htm'>List of Equations for Spring Motion</a>
</li>
- <li>
- <a href='https://www.ryanjuckett.com/damped-springs/'>Ryan Juckett's Explanation of Damped Springs</a>
- </li>
</ul>
</footer>
</article>