|
|
|
Record 16: Calculating distance between two points
function getDistance(x0,y0,x1,y1)
{
var dx=x1-x0;
var dy=y1-y0;
var sqr=Math.pow(dx,2)+Math.pow(dy,2);
return (Math.sqrt(sqr));
}
var a=15,b=26,c=18,d=30;
trace("The distance between ("+a+","+b+") and ("+c+","+d+") points is:"+getDistance(a,b,c,d));
---------------------------------------------------------------------------------
output
-------------------------------------------------------------------------------
The distance between (15,26) and (18,30) points is:5 |
|
|
|
|
|
|
|