FSINCOS and
FATAN2 are a complementary pair of
operators which convert angles to 2-vectors and vice-versa.
They are essential to most geometric and physical applications
since they correctly and unambiguously handle this conversion
in all cases except null vectors, even when the tangent of the
angle would be infinite.
FSINCOS returns a Cartesian unit vector in the direction
of the given angle, measured counter-clockwise from the positive
X-axis. The order of results on the stack, namely
y underneath
x, permits the 2-vector data type to be additionally viewed
and used as a ratio approximating the tangent of the angle.
Thus the phrase
FSINCOS F/ is functionally
equivalent to
FTAN, but is useful over only a limited
and discontinuous range of angles, whereas
FSINCOS and
FATAN2 are useful for all angles.
The argument order for
FATAN2 is the same, converting a
vector in the conventional representation to a scalar angle.
Thus, for all angles,
FSINCOS FATAN2 is an identity
within the accuracy of the arithmetic and the argument range of
FSINCOS. Note that while
FSINCOS always returns a
valid unit vector,
FATAN2 will accept any non-null vector.
An ambiguous condition exists if the vector argument to
FATAN2 has zero magnitude.