From 38d89c1182a61ca4e024e0834ae9187db76c67f8 Mon Sep 17 00:00:00 2001 From: mattkae Date: Sat, 26 Feb 2022 20:08:53 -0500 Subject: Fixing spring simulations and some write ups --- 2d/softbody/softbody_1.html.content | 87 ++++++++++++++++++++++++++++++++----- 1 file changed, 76 insertions(+), 11 deletions(-) (limited to '2d/softbody/softbody_1.html.content') 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 @@

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.

-

+

Undamped Spring Explanation

+

+ An undamped spring is one that never stops oscillating. Once an undamped spring starts moving back and forth, + it moves back and forth forever. +

+

+ 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 spring constant. + 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 equlibrium, which means that it is displaced by + 0m. This should make sense intuitively. +

+

+ One thing to note is that a damped spring has three cases: +

+ 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 c and k, so choose wisely for your use case. +

+

+ The equation is given as such: +

+ + ma + kx = 0 + +
+ where m is the mass, a is acceleration, k is the spring constant, and x is the current displacement + from the rest position. +

+

+ 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. +

-

- Undamped Springs -

+

+ Undamped Springs Example +

@@ -179,9 +216,40 @@

+
+

Damped Spring Explanation

+

+ 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 viscous damping constant (c) force + comes in. The damping force grows in proportion to the velocity. The equation is given as such: + +

+ + ma + cv + kx = 0 + +
+ + where m is the mass, a is acceleration, c is the damping constant, v is the velocity + k is the spring constant, and x is the current displacement from the rest position. +

+

+ 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 (x) will be negative and the velocity (v) 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! +

+ +

+ 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. +

+
+

- Damped Springs + Damped Springs Example

@@ -204,7 +272,7 @@ - + @@ -238,9 +306,6 @@

  • List of Equations for Spring Motion
  • -
  • - Ryan Juckett's Explanation of Damped Springs -
  • -- cgit v1.2.1