Move your mouse over the word to see the effect.

I have been getting back into OpenFrameworks lately and I have been using the OF vector library for all of the recent animations that I have been doing. I thought that I should give the AS3 Vector3D library a go. There are some limited, but useful functions built in. Making the move over to vector animation has made my coded animations more streamlined, if you are thinking about making the switch, consider the following code samples :


Without Vectors


var locX = 0, locY = 0;
var loc2X = 100;
var loc2Y = 50;

var dx = loc2X – locX;
var dy = loc2Y – locY;
var dist = Math.sqrt( (dx * dx) + (dy * dy) );


Utilizing Vectors


var loc:Vector3D = new Vector3D();
var loc2:Vector3D = new Vector3D(100, 50);

var dist2 = (loc2.subtract( loc )).length;

// or //
var dist3 = Vector3D.distance( loc, loc2 );

MORE INFO