Difference between revisions of "ATAN2"

From QB64 Wiki
Jump to navigation Jump to search
imported>Clippy
m
imported>SMcNeill
m (-)
(12 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
{{DISPLAYTITLE:_ATAN2}}
 
{{DISPLAYTITLE:_ATAN2}}
The '''_ATAN2''' function returns the radian angle between the positive x-axis of a plane and the point given by the coordinates (x, y) on it.
+
The [[_ATAN2]] function returns the radian angle between the positive x-axis of a plane and the point given by the coordinates (x, y).
  
  
 
{{PageSyntax}}
 
{{PageSyntax}}
::: angle! = '''_ATAN2(''' ''y'', ''x''''')'''
+
: {{Parameter|angle!}} = [[_ATAN2]]({{Parameter|y}}, {{Parameter|x}})
  
  
 
{{Parameters}}
 
{{Parameters}}
* ''y'' is the vertical axis position(row).
+
* {{Parameter|y}} is the vertical axis position (row) as a positive, zero or negative floating point value.
* ''x'' is the horizontal axis position(column).  
+
* {{Parameter|x}} is the horizontal axis position (column) as a positive, zero or negative floating point value.  
 +
 
  
 
{{PageDescription}}
 
{{PageDescription}}
* The [[DOUBLE]] radian angle returned is positive for upper row values where y > 0.
+
* The [[DOUBLE]] radian angle returned is '''positive''' for upper row values where y > 0.
* The [[DOUBLE]] radian angle returned is negative for lower row values where y < 0.
+
::* _ATAN2(y, x) = [[ATN]](y# / x#) when x > 0
* _ATAN2(y, x) = [[ATN]](y / x) when x > 0
+
::* _ATAN2(y, x) = [[ATN]](y# / x#) + [[_PI]] when x < 0
* _ATAN2(y, x) = [[ATN]](y / x) + [[_PI]] when x < 0 and y >= 0
+
::* _ATAN2(y, x) = [[_PI]] / 2 when x = 0
* _ATAN2(y, x) = [[ATN]](y / x) - [[_PI]] when x < 0 and y < 0
+
* The [[DOUBLE]] radian angle returned is 0 when x > 0 and [[_PI]] when x < 0 where y = 0
* _ATAN2(y' x) = [[_PI]] / 2 when x = 0 and y > 0
+
* The [[DOUBLE]] radian angle returned is '''negative''' for lower row values where y < 0.
* _ATAN2(y, x) = -[[_PI]] / 2 when x = 0 and y < 0
+
::* _ATAN2(y, x) = [[ATN]](y# / x#) when x > 0
* _ATAN2(0, 0) is undefined and the function returns 0.
+
::* _ATAN2(y, x) = [[ATN]](y# / x#) - [[_PI]] when x < 0
 +
::* _ATAN2(y, x) = -[[_PI]] / 2 when x = 0
 +
* _ATAN2(0, 0) is undefined and the function returns 0 instead of a division error.
  
  
 
{{PageErrors}}
 
{{PageErrors}}
* Note: With [[ATN]](y / x), x can never be 0! That would create a Division by Zero [[ERROR Codes|error]] 11.
+
* With [[ATN]](y / x), x can never be 0 as that would create a Division by Zero [[ERROR Codes|error]] 11 or #IND.
  
  
 
{{PageSeeAlso}}
 
{{PageSeeAlso}}
 
* [[ATN]] {{text|(arctangent)}}
 
* [[ATN]] {{text|(arctangent)}}
* [[_PI]] {{text|(QB64 constant value)}}
+
* [[_PI]] {{text|(QB64 function)}}
 
* [[Mathematical Operations]]
 
* [[Mathematical Operations]]
 +
* [https://en.wikipedia.org/wiki/Atan2 Atan2 reference]
  
  
 
{{PageNavigation}}
 
{{PageNavigation}}

Revision as of 13:26, 5 September 2017

The _ATAN2 function returns the radian angle between the positive x-axis of a plane and the point given by the coordinates (x, y).


Syntax

angle! = _ATAN2(y, x)


Parameters

  • y is the vertical axis position (row) as a positive, zero or negative floating point value.
  • x is the horizontal axis position (column) as a positive, zero or negative floating point value.


Description

  • The DOUBLE radian angle returned is positive for upper row values where y > 0.
  • _ATAN2(y, x) = ATN(y# / x#) when x > 0
  • _ATAN2(y, x) = ATN(y# / x#) + _PI when x < 0
  • _ATAN2(y, x) = _PI / 2 when x = 0
  • The DOUBLE radian angle returned is 0 when x > 0 and _PI when x < 0 where y = 0
  • The DOUBLE radian angle returned is negative for lower row values where y < 0.
  • _ATAN2(y, x) = ATN(y# / x#) when x > 0
  • _ATAN2(y, x) = ATN(y# / x#) - _PI when x < 0
  • _ATAN2(y, x) = -_PI / 2 when x = 0
  • _ATAN2(0, 0) is undefined and the function returns 0 instead of a division error.


Errors

  • With ATN(y / x), x can never be 0 as that would create a Division by Zero error 11 or #IND.


See also



Navigation:
Keyword Reference - Alphabetical
Keyword Reference - By usage
Main WIKI Page