ARCTAN2


10.0A

 

The ARCTAN2 instruction calculates the arctangent of the value of 'y/x' and returns a value in the range –pi to pi radians. The instruction uses the following format:

 

 

[label]

ARCTAN2

{sourcey}{sep}sourcex}{sep1}{dest}

 

Where:

label

Optional. A Program Execution Label.

sourcey

Required. A Numeric Variable, numeric Literal, or Expression specifying the 'y' value.

sep

Required. A comma or one of the following prepositions: BY, TO, OF, FROM, USING, WITH, IN, or INTO.

sourcex

Required. A Numeric Variable, numeric Literal, or Expression specifying the 'x' value.

sep1

Required. A comma or one of the following prepositions: BY, TO, OF, FROM, USING, WITH, IN, INTO, or GIVING.

dest

Required. A Numeric Variable that receives the arctangent of the ( sourcey/sourcex )

Flags Affected: LESS, OVER, ZERO

Note the following:

  1. The result is placed in the {dest} operand.

  2. The {sourcey} and {sourcex} operands remain unchanged.

  3. The calculated value of {dest} is expressed in radians.

  4. The EQUAL (or ZERO), OVER, and LESS Condition Flags are applicable.

  5. The rounding and truncation rules described in the section 'Numeric Variables' are applicable.

  6. If the environment variable PLB_ROUND is present, the result is rounded in accordance with the ANSI PL/B specification. Otherwise, the source operands are aligned and rounded, as applicable, to the destination operand's format.

  7. This instruction supports the mixing of variable types (FORM and INTEGER).

  8. Enhanced Array processing is supported.

  9. ARCTAN2 is not supported by the PLBCE runtime.

  10.  Note the following special scenarios:

  11.  

    1. If x equals zero, then

    2. Generate/bullet1.gif    1a) Arctan2 returns pi/2 if y is positive

      Generate/bullet1.gif    1b) Arctan2 returns -pi/2 if y is negative

    3.  Arctan2 returns zero if y is zero

Example of ARCTAN2:

 

Y

FORM

5.4

X

FORM

5.4

dest

FORM

8.4

.

 

 

 

MOVE

"1", Y

 

MOVE

"2", X

.

 

 

 

ARCTAN2

Y,X,dest

.

 

 

 

ARCTAN2

Y WITH X INTO dest

.

 

 

 

ARCTAN2

Y BY X GIVING dest

.

 

 

 

 

 

See Also: Example Code, Mathematical Instructions

 



PL/B Language Reference ARCTAN CALC