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:
|
|
|
|
|
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:
The result is placed in the {dest} operand.
The {sourcey} and {sourcex} operands remain unchanged.
The calculated value of {dest} is expressed in radians.
The EQUAL (or ZERO), OVER, and LESS Condition Flags are applicable.
The rounding and truncation rules described in the section 'Numeric Variables' are applicable.
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.
This instruction supports the mixing of variable types (FORM and INTEGER).
Enhanced Array processing is supported.
ARCTAN2 is not supported by the PLBCE runtime.
Note the following special scenarios:
If x equals zero, then
1a)
Arctan2 returns pi/2 if y is positive
1b)
Arctan2 returns -pi/2 if y is negative
Arctan2 returns zero if y is zero
Example of ARCTAN2:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
See Also: Example Code, Mathematical Instructions
![]() |