|
Hi,
I am trying to understand what I did wrong here. My function is found below.
This statement seems to yield a negative result when north1>north2 and east1>east2. How is this possible? Any help would be most appreciated!
((east2-east1)^2)+((north2-north1)^2)
When this expression is evaluted for further evaluation by the sqrt Math function, it returns a NaN (can't sqrt a negative number). It shouldn't be a negative number, unless I don't understand how javascript deals with statements.
function DISTANCE_CALC(north1,north2,east1,east2)
{
var north1=Number(north1);
var north2=Number(north2);
var east1=Number(east1);
var east2=Number(east2);
return Math.sqrt(((east2-east1)^2)+((north2-north1)^2));
}
|