And forgot the area of definition that is only PI not 2*PI...
A function working and consistent to the unit placement orientation for getting the angle of a vector from one point towards another is for example (perhaps not the best):
// Function to get the direction from one point to another
function getDirection(point1, point2)
{
var vector = [point2[0] - point1[0], point2[1] - point1[1]];
var output = Math.acos(vector[0]/getDistance(point1, point2));
if (vector[1] > 0) {output = PI + (PI - Math.acos(vector[0]/getDistance(point1, point2)))};
return (output + PI/2) % (2*PI);
};
The other functions are correct...
Edited by FeXoR, 29 February 2012 - 05:03 PM.













