Skip to content

shz_atan2f

Markdown
SHZ_INLINE float shz_atan2f(float y, float x) SHZ_NOEXCEPT;

Computes arctangent of y / x, using the signs of arguments to determine correct quadrant.

NameTypeDescription
yfloat
xfloat

float

Equivalent to C's atan2f().

Returns the angle of the vector (x, y) in radians, within [-pi, pi].

Accuracy: |shz_atan2f(y, x) - atan2(y, x)| <= 1.4e-5 radians with the default SHZ_ATAN2F_TERMS of 5 (#SHZ_ATAN2F_ERROR_MAX gives the bound for the configured value), for finite arguments with 2e-18 <= |x| + |y| <= 5e17. On the four axes the result is within 6e-7 of 0, +-pi/2, or pi for every setting.

  • shz_atan2f(+-0, +-0) returns 0. The result takes the sign of y, where a zero y of either sign counts as positive: shz_atan2f(-0.0f, -1.0f) is +pi where C's atan2f() gives -pi.
  • C++ equivalent: shz::atan2f
  • Type-generic form: none
  • Back-ends: SH4: shared C implementation · SW: portable C · SPU: shared C implementation
  • Defined in: sh4zam/shz_trig.h:250
  • Module: Trigonometry, section "Inverse Functions"

SHZ_ATAN2F_TERMS