Skip to content

ATN2 function takes the arguments reversed #110

@niroboo

Description

@niroboo

According to the documentation for ATN2 the first argument is numeric_expr_y and the second argument is numeric_expr_x and should equate to arctangent of y/x.

After testing I found out that cosmosdb-server has the arguments reversed.

Example from documentation:

SELECT VALUE {
    arctangentInRadians: ATN2(35.175643, 129.44)
}
[
  {
    "arctangentInRadians": 0.265344532064832
  }
]

A test I wrote to verify the behavior:

    describe('ATN2', () => {
      it('should support ATN2()', async () => {
        const y = 35.175643;
        const x = 129.44;
        const v = Math.atan2(y, x);

        const query = `SELECT ATN2(${y}, ${x}) as atn2`;
        const { resources } = await container.items.query(query).fetchAll();
        expect(resources[0].atn2).toBeCloseTo(v);
      });
    });

When I flip y and x it does work:

const query = `SELECT ATN2(${x}, ${y}) as atn2`; // Purposely flipped y/x

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