Math.atan2.js 1.4 KB

12345678910111213141516171819202122232425262728
  1. test("basic functionality", () => {
  2. expect(Math.atan2).toHaveLength(2);
  3. expect(Math.atan2(90, 15)).toBeCloseTo(1.4056476493802699);
  4. expect(Math.atan2(15, 90)).toBeCloseTo(0.16514867741462683);
  5. expect(Math.atan2(+0, -0)).toBeCloseTo(Math.PI);
  6. expect(Math.atan2(-0, -0)).toBeCloseTo(-Math.PI);
  7. expect(Math.atan2(+0, +0)).toBe(0);
  8. expect(Math.atan2(-0, +0)).toBe(-0);
  9. expect(Math.atan2(+0, -1)).toBeCloseTo(Math.PI);
  10. expect(Math.atan2(-0, -1)).toBeCloseTo(-Math.PI);
  11. expect(Math.atan2(+0, 1)).toBe(0);
  12. expect(Math.atan2(-0, 1)).toBe(-0);
  13. expect(Math.atan2(-1, +0)).toBeCloseTo(-Math.PI / 2);
  14. expect(Math.atan2(-1, -0)).toBeCloseTo(-Math.PI / 2);
  15. expect(Math.atan2(1, +0)).toBeCloseTo(Math.PI / 2);
  16. expect(Math.atan2(1, -0)).toBeCloseTo(Math.PI / 2);
  17. expect(Math.atan2(1, -Infinity)).toBeCloseTo(Math.PI);
  18. expect(Math.atan2(-1, -Infinity)).toBeCloseTo(-Math.PI);
  19. expect(Math.atan2(1, +Infinity)).toBe(0);
  20. expect(Math.atan2(-1, +Infinity)).toBe(-0);
  21. expect(Math.atan2(+Infinity, 1)).toBeCloseTo(Math.PI / 2);
  22. expect(Math.atan2(-Infinity, 1)).toBeCloseTo(-Math.PI / 2);
  23. expect(Math.atan2(+Infinity, -Infinity)).toBeCloseTo((3 * Math.PI) / 4);
  24. expect(Math.atan2(-Infinity, -Infinity)).toBeCloseTo((-3 * Math.PI) / 4);
  25. expect(Math.atan2(+Infinity, +Infinity)).toBeCloseTo(Math.PI / 4);
  26. expect(Math.atan2(-Infinity, +Infinity)).toBeCloseTo(-Math.PI / 4);
  27. });