Chaos Pendulum

We saw a program that had a double pendulum called the chaos pendulum and my girlfriend said I should try and make it, so I had a quick play in quickbox2d. It was being used as an example of chaotic looking movement that wasn’t random. Here’s a real one.

and here’s the flash on, it’s not as good but box2d does an interesting job.

let’s test putting some code on here.. ┬áthen you need to get quickbox2d

import com.actionsnippet.qbox.*;
stage.frameRate = 60;

var sim:QuickBox2D = new QuickBox2D(this);

var $x:Number = 9
var $y:int = 4
var $length:int = 5
var $radius:Number = 0.5

var pin_to:QuickObject = sim.addBox({x:$x, y:$y, width:0.5, height:0.25,density:0, maskBits:0x0008 } );
var top_pendulum:QuickObject = sim.addBox({x:$x, y:$y+($length * 0.5), height:$length,width:1.5,friction:0,restitution:0 } );
var bottom_pendulum:QuickObject = sim.addBox({x:$x, y:$y + ( $length * 1.3 ), height:$length,width:0.75,friction:0,restitution:0 } );

//SET UP JOINTS
sim.addJoint( {type:"revolute",a:pin_to.body,b:top_pendulum.body,collideConnected:false, x1:$x, y1:$y, x2:$x, y2:$y } );
sim.addJoint( {type:"revolute",a:top_pendulum.body,b:bottom_pendulum.body,collideConnected:false, x1:$x, y1:$y+( $length * 0.9 ), x2:$x, y2:$y+$length-0.25 } );

sim.start();
sim.mouseDrag();

//ADD RANDOM ANGULAR VELOCITY ON CLICK
//JUST SETTING THE bottom_pendulum SEEMS TO WORK
stage.addEventListener( MouseEvent.CLICK, clicked );

function clicked( e:MouseEvent ):void
{
bottom_pendulum.body.SetAngularVelocity( 10000-Math.random() * 20000 )
}
This entry was posted in experiments. Bookmark the permalink.

Comments are closed.