Skip to content

p_atan2.c is b/a or a/b? #223

@twocs

Description

@twocs

Looking at the relevant lines of p_atan2.c at https://github.com/parallella/pal/edit/master/src/math/p_atan2.c

  • Calculates the inverse tangent (arc tangent) of b/a. Stability not guaranteed
  • for 'a' values near 0. Results are in the range of -pi to pi.
  • @param a Pointer to denominator input vector
  • @param b Pointer to numerator input vector
    void p_atan2_f32(const float *a, const float *b, float *c, int n)

Contrast this with atan2 ISO/IEC 9899:1999 (E)
The atan2 functions compute the value of the arc tangent of y/x, using the signs of both
arguments to determine the quadrant of the return value. A domain error may occur if
both arguments are zero.
double atan2(double y, double x);

In my impression, the signature of atan2(y, x) becomes atan(y/x) with some edge conditions.
However, the signature of p_atan2(a, b, ...) becomes atan(b/a) [or equivalently p_atan2(y, x, ...) becomes atan(x/y)].

Isn't this inverted? Is it intentional?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions