Pages

Showing posts with label Books. Show all posts
Showing posts with label Books. Show all posts

Sunday, January 28, 2024

Chain Change

Recently I've been rereading the book Seveneves by Neal Stephenson, which opens with the Moon being destroyed by an unknown object, forcing humanity to flee the surface of the Earth before the debris comes through the atmosphere. One of the engineers that goes into space notices something interesting about the chain he wears:

[He] had got it spinning around his neck. It had opened up into a broad, undulating oval that didn't touch his neck or collar anywhere, so it was just orbiting around him in free space. [...] He had learned a few tricks for speeding it up and coaxing it into different shapes by blowing on it with a drinking straw or flicking it with a fingernail. [...He] poked an index finger up into the chain's path. It caught on his knuckle, hiccupped, and suddenly wrapped around his hand in a chaotic tangle.

I was really curious if I could simulate some of these effects, so I came up with a simple model for the chain: A circle of points that are connected to each other by simple springs. The force applied by the springs is proportional to how far each point is from its neighbors, so the circle will tend to collapse to a point, but if we set it spinning, then just like an orbit we can keep the points from falling inward. We can see what happens if we tap one of the nodes:

This shows some really nifty behavior: Part of the poke moves around the circle in the direction of rotation, but there's also a dent that stays fairly stable until the other part of the poke comes around again. You might also notice when the animation loops that the chain has moved off-center by a fair amount. That made me wonder what would happen if I poked it symmetrically on each side:

Now the chain stays centered, but becomes more ellipsoidal, with the long axis rotating with the nodes. So far, so good – Let's try sticking a finger in it!

Hmm, not quite what we were looking for. To model the "finger," I checked at every step whether each node was inside the finger's radius. If it was, I would move it to the nearest point outside. Unfortunately, this meant that if I moved the finger much further in than I do above, links would start popping to the outside, which sounds painful for our simulacrum! I do like the faux-3D helix the chain forms on the other side of the finger though. 

Sunday, May 19, 2019

Intelligent Falling

[Title refers to the equally credible explanation for gravity.]

I'm in the middle of reading Seveneves, by Neal Stephenson, which involves humanity fleeing the surface of Earth to survive in orbit. All the discussion of orbital mechanics reminded me of a program I loved playing with when I was growing up called Gravitation, Ltd. It let you set up bodies of different masses in space, and let them move according to each other's gravity. What I particularly liked seeing was the different patterns the orbits would make. Since that application is more than 20 years old at this point, I was curious if I could set up another HTML5 widget to play with.

For any pair of objects, Newton's Law gives the acceleration of one object created by the other:
where G is Newton's constant, m is the mass of the attracting object, and r is the vector from the accelerating object to the attracting one. This is a second-order differential equation for the position of the body: The equation gives an acceleration, which is the change in velocity, which is the change in position. At every step of time in our simulation, we need to find the acceleration, and from that get the velocity and position. The natural way to do that, integrating up from acceleration, would be
where the subscript indicates the step number. This is called Forward Euler Integration. For certain systems though, this method can be unstable, producing results that diverge to infinity. A more robust technique is Backward Euler Integration, which does the calculation in the opposite order:
Both are implemented below, but I haven't noticed much difference for the cases I've tried. Play around a bit, and be sure to post interesting settings in the comments!

Canvas not supported; please update your browser.

Initial Position


Initial Velocity


Star Mass


Method