Archive for the 'Math' Category

Truncating numbers in actionscript…

So there’s no built in method to truncate a number in actionscript. Well a bit of playing around and a simple work around is just as good.

As most of you will know String’s can be truncated via substr();.

Well just typecast your value to be truncated to a String, call the substr(), using the length of the string minus your amount of digits to trincated, then typecast it back to a Number.

Code:

1
2
3
4
function truncate(val:String,truncCount:uint):String
{
	return val.substr(0,val.length-truncCount);
}

To use:

1
2
3
4
var num:Number = 56.673856;
trace(num)//56.673856
num = Number(truncate(num.toString(),5));
trace(num)//56.6
Vote in HexoSearch Vote for this on HexoSearch!

More Isometrics

Playing around with isometrics, perlin noise and sine waves. Something I have wanted to do for a while.

Anyway first app uses perlin noise for height or y pos depending if floating or not, click to toggle floating and randomise the x and y offset’s for the perlin noise.

The second app is using a simple sine wave accross a grid, well the first isometric block is using a sine, the rest just of the blocks just set their height or y pos to the one before it, again click to toggle floating.

Vote in HexoSearch Vote for this on HexoSearch!

Cantor Cheese Cross Sections…Yes Cheese!

Yet some more of the book, not long after i posted the flutterby experiments.

Renders very quick but kinda expected it to as it is very simple, 3D maybe…?

Click to generate a new set of coloured cross sections…

Vote in HexoSearch Vote for this on HexoSearch!

Flutterby Curves

Another bit of the book, and also a bit of ceverage by Keith at artfromcode.

Decided to optimize as much as possible and results were good, first app click to create a new butterfly at mouse’s coordinates.





Second app ‘Butterfly Trails’, every tenth of a second a new butterfly is created and pointing towards the mouse [cheap effect i know but looks good :-P ], runs quite smoothly even on an older system :-) .



Vote in HexoSearch Vote for this on HexoSearch!