Author Archives: Zevan

QuickBox2D 1.0

QuickBox2D 1.0 is ready. It contains a bunch of small bug fixes and a few new features that I’ll be demoing in the next few posts. The main new features relate to collision detection and simple event sequencing.
Go download it from here…
I also spent some time updating the docs…. everything is documented… I may add [...]

Posted in Box2D, QuickBox2D | Tagged , , , , | 2 Comments

drawTriangles() Cubes

CLICK HERE TO COPY
Actionscript:

private function addCube(xp:Number, yp:Number, zp:Number, w:Number, h:Number, leng:Number):void{

            var hw:Number = w * 0.5;

            var hh:Number = h * 0.5;

            var hl:Number = leng * 0.5;

            var xA:Number = xp - hw;

  [...]

Posted in 3D, Graphics, Vector, matrix, motion | Tagged , , | 6 Comments

Calculate Surface Area and Volume of a Sphere

CLICK HERE TO COPY
Actionscript:

var rad:Number = 1;

 

var surfaceArea:Number = sphereSurfaceArea(rad);

var volume:Number = sphereVolume(rad)

trace("surface area: ", surfaceArea);

trace("volume:", volume);

trace("volume / surface area:", volume / surfaceArea);

 

function sphereSurfaceArea(r:Number):Number{

    return 4 * Math.PI * r * r;

}

 

function sphereVolume(r:Number):Number{

    return r * r * r * (4.0/3.0) * Math.PI;

}

 

/*outputs:

surface area:  12.566370614359172

volume: 4.1887902047863905

volume / surface area: 0.3333333333333333

*/

Last night I was [...]

Posted in Math, misc | Tagged , , , | 2 Comments

QuickBox2D addTimeStepSequence() Preview

CLICK HERE TO COPY
Actionscript:

import com.actionsnippet.qbox.*;

 

[SWF(width = 800, height = 600, backgroundColor = 0xFFFFFF, frameRate=60)]

 

// hide everything for 300 ms

visible = false;

setTimeout(function():void{ visible = true}, 300);

 

var canvas:MovieClip = MovieClip(addChild(new MovieClip()));

 

var sim:QuickBox2D = new QuickBox2D(canvas, {debug:true});

 

sim.setDefault({fillColor:0x666666, lineAlpha:0})

sim.createStageWalls();

 

var boxA:QuickObject = makeLever(6 , 17.5, 9, "right", 0.7);

var circleA:QuickObject = sim.addCircle({x:2, y:3, radius:0.5, mass:4});

sim.addBox({x:15, y:12, width:2, height:0.5, density:0})

var circleB:QuickObject = [...]

Posted in Box2D, QuickBox2D, motion | Tagged , , , | 1 Comment