ATN2

From MCS Wiki AVR
(Difference between revisions)
Jump to: navigation, search
(Created page with "= <span class="f_Header">Action</span> = ATN2 is a four-quadrant arc-tangent. While the ATN-function returns from -p/2 (-90°) to p/2 (90°), the ATN2 function returns the w...")
 
 
Line 25: Line 25:
  
 
| valign="top" width="100%" style="width: 480px; border: 1px solid rgb(0, 0, 0);" |  
 
| valign="top" width="100%" style="width: 480px; border: 1px solid rgb(0, 0, 0);" |  
A single variable that is assigned with the ATN2 of variable single.
+
A floating point variable that is assigned with the ATN2 of variable single.
  
 
|- style="vertical-align: top;"
 
|- style="vertical-align: top;"
Line 32: Line 32:
  
 
| valign="top" width="100%" style="width: 480px; border: 1px solid rgb(0, 0, 0);" |  
 
| valign="top" width="100%" style="width: 480px; border: 1px solid rgb(0, 0, 0);" |  
The single variable with the distance in x-direction.
+
The float variable with the distance in x-direction.
  
 
|- style="vertical-align: top;"
 
|- style="vertical-align: top;"
Line 39: Line 39:
  
 
| valign="top" width="100%" style="width: 480px; border: 1px solid rgb(0, 0, 0);" |  
 
| valign="top" width="100%" style="width: 480px; border: 1px solid rgb(0, 0, 0);" |  
The single variable with the distance in y-direction
+
The float variable with the distance in y-direction
  
 
|}
 
|}

Latest revision as of 19:37, 15 June 2015

Contents

Action

ATN2 is a four-quadrant arc-tangent.

While the ATN-function returns from -p/2 (-90°) to p/2 (90°), the ATN2 function returns the whole range of a circle from -p (-180°) to +p (180°). The result depends on the ratio of Y/X and the signs of X and Y.

 

 

Syntax

var = ATN2( y, x )

 

 

Remarks

Var

A floating point variable that is assigned with the ATN2 of variable single.

X

The float variable with the distance in x-direction.

Y

The float variable with the distance in y-direction

 

 

Atn2.gif

 

Quadrant

Sign Y

Sign X

ATN2

I

+

+

0 to p/2

II

+

-

p/2 to p

III

-

-

-p/2 to -p

IV

-

+

0 to –p/2

 

If you go with the ratio Y/X into ATN you will get same result for X greater zero (right side in coordinate system) as with ATN2. ATN2 uses X and Y and can give information of the angle of the point over 360° in the coordinates system.

 

All trig functions work with radians. Use deg2rad and rad2deg to convert between radians and angles.

 

 

See Also

RAD2DEG , DEG2RAD , COS , SIN , TAN , ATN

 

 

Example


$regfile = "m48def.dat" ' specify the used micro
$crystal = 8000000 ' used crystal frequency
$baud = 19200 ' use baud rate
$hwstack = 32 ' default use 32 for the hardware stack
$swstack = 10 ' default use 10 for the SW stack
$framesize = 40 ' default use 40 for the frame space
 
Config Com1 = Dummy , Synchrone = 0 , Parity = None , Stopbits = 1 , Databits = 8 , Clockpol = 0
 
 
Dim S As Single , X As Single
X = 0.5 : S = 1.1
S = Atn2(s , X)
Print S ' prints 1.144164676
 
End

Languages   English Deutsch  
Personal tools
Namespaces
Variants
Actions
Navigation
In other languages
Language