RSS

Archive for the ‘Algorithms’ Category

December 18th, 2010 - 12:48 PM § in Algorithms

Matrix Transformation

As many of you may be aware, the flash package contains a geom.Matrix class which is useful for Linear Translations of DisplayObjects as well as BitmapData. The matrix class allows for a 3×3 array which is useful for 2D transformations such as shearing, rotation, and scaling. Of course with any[...]

June 30th, 2010 - 11:02 AM § in Algorithms

Faster Pixel Loop Itteration

Using multiple loops, can always become a difficult way to manage and I wanted to share another way to accomplish a traverse of a full BitmapData more effeciently.[...]

June 18th, 2010 - 10:16 PM § in Algorithms

Random Distribution

A few years ago, I remember learning from Keith Peters, who learned from Sean O’Shell, that you could get Math.random() to favor 1 through its square root. Math.sqrt(Math.random()) Recently, during a client project, I needed the values returned between 0-1 to be somewhat larger, while still re[...]

February 21st, 2010 - 3:38 PM § in Algorithms

Wandering

vx+=Math.random()*2-1; vy+=Math.random()*2-1; clip.x+=vx clip.y+=vy vx*=.9 vy*=.9 }[...]

February 18th, 2010 - 8:07 AM § in Algorithms

Barslund Repulsion

xDif = mouseX-this.x; yDif = mouseY-this.y; distance = Math.sqrt(xDif*xDif+yDif*yDif); tempX = this.x-(force/distance)*(xDif/distance); tempY = this.y-(force/distance)*(yDif/distance); this.x=(this.homeX-this.x)/2+tempX; this.y=(this.homeY-this.y&#[...]