In this episode of the podcast I talk about a nice approach to a genetic code for the system, not based on bytes but right down to the bits. It's all about ones and zeros in computers, so this is the level of our genetic instructions.

We can always draw a binary tree where each node has two subnodes, except for the leaves of the tree. Then every bit we read from the gene can make us step left or right as we ascend the tree to reach a leaf. When we reach a leaf, we shout the word that's "written on it". Problem with this approach is that one bit flip changes the meaning of everything that follows.

Instead we go for a delimiter approach where 00 becomes a delimiter. Then you can look at a string of bits as a string of words separated by pairs of zeroes. So this string of bits 001010010101010011100110101101 becomes 00 101 00 1010101 00 111 00 110101101. remove the delimiters and you get the words: { "","101","1010101","111","110101101" }.

The number of possible words of length N is the the (N+1)th Fibonacci number. The Fib sequence is 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89,... where each number is the sum of the two that preceded it.

Not only that, but the frequencies of the different words are very divergent. Long words are rare, of course.

Somehow these words have to come to "mean something" to the elements of the tensegrity which are growing during the embryology phase. Perhaps some infrequent words would mean "replicate" and some frequent words would mean "grow" or "connect". Play with the binary code and the delimiters and let me know what you think.

Technorati Tags:

There's a new version of the Tensegrity Application online for you to take a look at. You will notice that there's text at the top describing how long the bars are, and if you watch you will see that every new tensegrity that appears is smaller than the previous one. The nice effect of getting smaller is that the cable forces really start to dominate eventually, while they are relatively weak in the beginning. Think about this.

I've been busy building a rendering where the bars appear to be substantial things, shaped a bit like cigars, while the cables are still appearing as blue lines. To do this and keep things flexible I've taken the bar and cable painters out of the view class, and made them separate little classes. Below you will find links to the SphereBarPainter and the LineCablePainter.

Also, while setting up the visualization of the new tensegrity triangle unit from last time (three bar tensegrity) it became clear that we need a good way to maintain the camera position. For this I created a class Vehicle, the source of which is also linked below. The Vehicle takes the PointOfView and manipulates it during every tick of the clock, trying to move it towards focusing on an ideal focus location and maintain an ideal distance from that focus. In the view class, all we have to do is call its "adjust" method and it will push the PointOfView one more step in the right direction.

You should be able to see the results of this in how you find yourself following the tensegrity as it bounces around in the new version online. You will also see the lovely three-bar tensegrity that is created by the little factory method from last time.

I'm afraid I've also been doing quite a bit of tweaking to figure out how to make the gravity and the floor work in an good-looking way. Here is the relevant code from Physics.java if you're interested:


        float downward = gravity*mass;
        float localDrag = joint.velocity.quadrance() * drag;
        float damping = DAMPING;
        float height = joint.location.z;
        if (height < BUFFER_ZONE) {
            float antigravity = downward * ANTIGRAVITY_FACTOR;
            float highDamping = damping * DAMPING_FACTOR;
            float killXY;
            if (height > -BUFFER_ZONE) {
                // 1 at top, 0 at bottom
                float above = (height + BUFFER_ZONE)/(BUFFER_ZONE*2);
                // 0 at top, 1 at bottom
                float below = (BUFFER_ZONE - height)/(BUFFER_ZONE*2);
                downward = downward * above + antigravity * below;
                damping = damping * above + highDamping * below;
                killXY = above;
            }
            else {
                downward = antigravity;
                damping = highDamping;
                killXY = 0;
            }
            momentum.x *= killXY;
            momentum.y *= killXY;
        }
        momentum.z -= downward;
        momentum.scale(1 - localDrag);
        momentum.scale(1 - damping);
        .....

As you can see I've added in damping (just reduces momentum, regardless of velocity) and also added functionality to kill the X and Y momentum when a joint goes below the floor (anti-slipperiness). Other than that, the gravity gradually gives in to the antigravity the further down you are. It's fun to play around with physics, but I realize that I will eventually have to settle on a physics strategy that I can defend well.

In this episode of the podcast I talk about this stuff, and I read a little section of Bucky Fuller's book "Synergetics 2". I received this book in the mail from the man who co-authored it with Fuller himself Ed Applewhite with the inscription "For Gerald de Jong - in gratitude for his imaginative amplification of Fuller's ideas as found in this work".

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;
    }

Technorati Tags: