Pages

Friday, December 28, 2018

Wag the Dog, Part 2

Long ago, at almost the beginning of this blog, I wrote a post with an attempt at analyzing the goofy wagging behavior of my family's two dogs. I failed to come up with a satisfying answer then (in my defense, chemo) but my friend Chris pointed out that I would have had an easier time using Lagrangian mechanics.

Marika and I have a dog of our own now, Lorna, and she does the exact same vigorous wagging I described before. Marika even gave her the nickname "Stubby Wigglekins", due to her stubbornness with me, and her crazy wagging for Marika. I'm missing the two of them here in France, but with a bit of mathematical modeling, maybe I can get a temporary Lorna stand-in!

We'll consider the dog in three parts: body, butt, and tail. The two joints connecting these parts act like springs, applying a force to bring them straight. The magnitude of the force depends on how much they're bent:

Lagrangian mechanics are entirely equivalent to Newton's approach, but are often easier to work with in cases where energy is conserved. The technique involves first defining the difference between kinetic and potential energy in the system:
The advantage of Lagrangian mechanics is that we're allowed to parameterize the system in whatever terms we want, like the angle of the joints rather than their x/y coordinates. For each joint, we can use the usual results for a spring:

where I is the rotational inertia, 𝜅 is the strength of the spring, and the dot indicates a time derivative. Summing the results from the two joints and plugging in gives
Hamilton's principle says that the integral of this in time should be stationary in the parameters 𝜃1, 𝜃2, and their derivatives. Luckily, we don't actually need to do the integral, and can instead just plug into the general equations this leads to. For each 𝜃, we can write the equation
Applying this to the Lagrangian from earlier,

Much simpler than what I was doing last time, and all because we're working in terms of the angles, and not the x/y position! I decided to put together another HTML5 doodad to experiment with:

Canvas not supported; please update your browser.

Amplitude 1


Amplitude 2


Stiffness 1


Stiffness 2


Tail Length




Fun to play with, but no substitute for the original!


1 comment: