i needed to calculate the angle between 2 points/vectors in 3d space.
there was a function in the number3d library but it didn't tell me the
direction (clockwise or counterclockwise). so i google it and found
that on a 2D space you can calculate the direction with the help of a
determinant
D(A, B) = A.x * B.y - A.y * B.x. if D<0 clockwise else
counterclockwise (or viceversa, but doesn't matter). so i implemented
it in the library and it works well. i used the x and z, thinking of
the projections of the 2 vectors onto the xz plane. so if you need
this sort of calculation just add/replace these lines of code in the
number3d library.
public function getAngle(w:Number3D = null):Number
{
if (w == null)
w = new Number3D();
if ((x * w.z - z * w.x) < 0)
return -Math.acos(dot(w)/(modulo*w.modulo));
else
return Math.acos(dot(w)/(modulo*w.modulo));
}