Javascript: Formula to get Direction from X, Y Coordinates
<p>Hey, this just derived from Microsoft, suprise, suprise.  I was just making a little util to quickly do drop shadows with CSS, and realized that it can only be duplicated in IE with filters.  The Shadow filter however uses direction instead of x, y coordinates.</p>

<pre><code>filter: "progid:DXImageTransform.Microsoft.Shadow(Strength=4, Direction=135, Color='#000000');"
</code></pre>

<p>any idea how to calculate the direction from x,y coordinates?</p>

<p>EDIT##################################33
Using the responses given and more details from this link: <a href="http://www.teacherschoice.com.au/Maths_Library/Angles/Angles.htm" rel="nofollow">http://www.teacherschoice.com.au/Maths_Library/Angles/Angles.htm</a>, I modified my code as follows:</p>

<pre><code>function(x, y){
    var d = Math.atan2(x, y) * (180 / Math.PI);
    if(d &lt; 0){ d = 180 - d; }
    return d;
}
</code></pre>

<p>If you pass in Horizontal Offset and Vertical Offset that you would use as X, Y respectively, you will get a degree from 0 to 359</p>
