angle between two points in javascript

//——— to get angle between two points ———
//—param—
//@x1,x2,y1,y2 : cordinates of 2 points
//@return: theta(value in degrees)
function getTanTheta(x1,y1,x2,y2)
{
var y = eval(y2)-eval(y1);
var x = eval(x2)-eval(x1);

if(y < 0) { y = -y;}
if(x < 0) { x = -x;}

//alert(y+’  ‘+x);
var tanTheta = y/x;
if(tanTheta < 0) { tanTheta = -x;}

tanTheta = roundNumber(tanTheta,3);
//alert(tanTheta);
return tanTheta;

}
Advertisements

Say something : I accept all the "Humer&Critic"

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s