A weired issue I am struggling with to find angle between two vectors using built-in function
var v1:Vector3D = new Vector3D(0, 0, 0);
var v2:Vector3D = new Vector3D(50, 0, 50);
//Vector3D(0, 0, 0) Vector3D(50, 0, 50)
var angle1:Number = Vector3D.angleBetween(v1,v2) * 180 / Math.PI;
var angle2:Number = Vector3D.angleBetween(v2,v1) * 180 / Math.PI;
trace(angle1,angle2);
This returns NaN for both angle1 and angle2
However, if I pass a non-zero value (any smaller number such as 0.00001) as y property to any of the vector then I get the number/angle
For this reason, I am cloning my vectors and adding a small number (0.00001) to y before calling this method.
I am not sure if I am doing something wrong or its a bug there. Can some one help?
Vector(0,0,0) has infinity angles, and 0 size (from def.). that’s why there is no angle between.
you can add
to make it work the way you want.