Quick References
      ADO
      ASP
      CSS2
      HTML
      JavaScript
      Jet SQL
      VBScript
      WML
      WMLScript
      WSH
      XHTML
      XML DOM
      XSLT

Features
      Knowledge Base
      Tutorials

Partners
     ZVON.ORG
     XML
     Planet Source Code
     VisualBuilder
     Web Design
     Your HTML Source
     XML/XSLT Forums
     ASPAlliance
     Scripts
     
     Programmers Heaven
     Tek-Tips Forums
     Developer Fusion
     Code Project











METHOD:  Math::atan2


Math.atan2(y, x)
 
The atan2 method returns the arctangent of the quotient of its two arguments. Compare this to the atan method whose single argument is the ratio of these two co-ordinates. Specifically, the angle returned is a numeric value between PI and -PI and represents the counterclockwise angle in radians (not degrees) between the positive X axis and the point (x, y).
 
NOTE:
 
The y co-ordinate is passed as the first argument and the x co-ordinate is passed as the second argument, i.e. atan2(y, x). This is purposeful and is agreement with the ECMA-262 standard.
 
Assuming you had a point with the (x, y) co-ordinates of (3, 6), you could calculate the angle in radians between that point and the positive X axis as follows:
 
Code:
Math.atan2(6, 3)
 
output:
0.4636476090008061
 
This is equivalent to calculating the arctangent of the ratio of these two co-ordinates, which is 6/3 = 2, as follows:
 
Code:
Math.atan(2)
 
output:
0.4636476090008061

 


Copyright 1999-2005 by Infinite Software Solutions, Inc. All rights reserved.
Trademark Information