ATAN2: Difference between revisions

From QB64 Phoenix Edition Wiki
Jump to navigation Jump to search
(Created page with "{{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). {{PageSyntax}} : {{Parameter|angle!}} = _ATAN2({{Parameter|y}}, {{Parameter|x}}) {{Parameters}} * {{Parameter|y}} is the vertical axis position (row) as a positive, zero or negative floating point value. * {{Parameter|x}} is the horizontal axis position (column) as a positive, zero or negative floating poin...")
 
No edit summary
 
(11 intermediate revisions by the same user not shown)
Line 7: Line 7:




{{Parameters}}
{{PageParameters}}
* {{Parameter|y}} is the vertical axis position (row) as a positive, zero or negative floating point value.
* {{Parameter|y}} is the vertical axis position (row) as a positive, zero or negative floating point value.
* {{Parameter|x}} is the horizontal axis position (column) as a positive, zero or negative floating point value.  
* {{Parameter|x}} is the horizontal axis position (column) as a positive, zero or negative floating point value.




Line 17: Line 17:
::* _ATAN2(y, x) = [[ATN]](y# / x#) + [[_PI]] when x < 0
::* _ATAN2(y, x) = [[ATN]](y# / x#) + [[_PI]] when x < 0
::* _ATAN2(y, x) = [[_PI]] / 2 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 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.
* 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
Line 24: Line 24:
* _ATAN2(0, 0) is undefined and the function returns 0 instead of a division error.
* _ATAN2(0, 0) is undefined and the function returns 0 instead of a division error.


 
=== Errors ===
{{PageErrors}}
* With [[ATN]](y / x), x can never be 0 as that would create a Division by Zero [[ERROR Codes|error]] 11 or #IND.
* 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 function)}}
* [[_PI]] {{Text|(QB64 function)}}
* [[Mathematical Operations]]
* [[Mathematical Operations]]
* [https://en.wikipedia.org/wiki/Atan2 Atan2 reference]
* [[Wikipedia:Atan2|Atan2 reference]]




{{PageNavigation}}
{{PageNavigation}}

Latest revision as of 16:28, 14 June 2024

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:
Main Page with Articles and Tutorials
Keyword Reference - Alphabetical
Keyword Reference - By usage
Report a broken link