Tue, 6 Nov 2007
Mass = Span * Span * Span
« Larvae and the Ghost of Proximity | Main | Cigars and Antigravity » Posted by at 10:40 PM in Code
What is mass? For the purposes of this program we need not have something that is exactly replicates the real world physics, but it has to be a correct analogy given the assumptions behind the project. A while ago I mentioned that we are assuming that the tension cables are effectively weightless, so our only concern is the bars when we talk about mass. Now if a real world bar of span S has a particular mass value M (related to the number of atoms), then how much mass would a bar twice as long have? The number of atoms does not double, but instead the whole bar has to get longer and thicker at the same time. Length, width, and height have to double, which means that the double-length bar has 2 * 2 * 2 = 8 times us much mass (as many atoms). So a function has been added to Bar.java:
public float getMass() {
return span*span*span;
}
As you can see, there are no units here. No centimeters or grams. Why? Because this program is analogous to physical reality, but not a copy. Clearly a doubling causes a multiplication by eight, so we're good with respect to increasing and decreasing. The nice thing is that this is all we need.
Now, what does mass actually do? For that we have to visit Physics.java again. First, mass affects the amount of force downwards that gravity has on objects. So a bar twice as long will be pulled downwards eight times as hard. Another effect that gravity has in the real world is that it affects how much a standing object wants to stand still, or how much a moving object wants to keep moving. Inertia is directly related to mass. Momentum is the word used to describe the velocity times the mass of an object. It's momentum that is conserved when one billiard ball bounces against another. Force is defined as a change of momentum relative to time. We need momentum.
So now in the Physics class, the move method works with momentum by setting the momentum arrow to the velocity arrow, scaled by the mass. It's the momentum upon which the forces act. When all of the forces have done their work, the new momentum is scaled down by mass to set the velocity.
In this episode 25 of the podcast, I talk about mass and how it affects the physics, as well as this lovely gem:
public Tensegrity createThreeBar() {
Tensegrity t = new Tensegrity();
Bar b0 = t.createBar(
new Arrow(ZERO, ZERO, ZERO),
new Arrow(ZERO, ZERO, ONE),
ONE
);
Bar b1 = t.createBar(
new Arrow(-HALF, ZERO, HALF),
new Arrow(HALF, ZERO, HALF),
ONE
);
Bar b2 = t.createBar(
new Arrow(ZERO, -HALF, HALF),
new Arrow(ZERO, HALF, HALF),
ONE
);
t.createBarJoint(b2,b0.alpha);
t.createBarJoint(b1,b0.omega);
t.createBarJoint(b0,b1.alpha);
t.createBarJoint(b2,b1.omega);
t.createBarJoint(b0,b2.alpha);
t.createBarJoint(b1,b2.omega);
return t;
}
- Physics.java - works with momentum now
Technorati Tags: evolution tensegrity java darwin