static double atan2(double y, double x) {
        // kludge to prevent 0/0 condition
        double absY = Math.abs(y) + 1e-10;
        double r, angle;
        if (x < 0.0) {
            r = (x + absY) / (absY - x);
            angle = PI3_4;
        } else {
            r = (x - absY) / (x + absY);
            angle = PI_4;
        }

        angle += (0.1963 * r * r - 0.9817) * r;
        if (y < 0.0)
            // negate if in quad III or IV
            return -angle;
        return angle;
    }
@Test
    public void testAtan2() {
        // assertEquals(0, AngleCalc.atan2(0, 0), 1e-4);
        // assertEquals(0, AngleCalc.atan2(-0.002, 0), 1e-4);
        assertEquals(45, AngleCalc.atan2(5, 5) * 180 / Math.PI, 1e-2);
        assertEquals(-45, AngleCalc.atan2(-5, 5) * 180 / Math.PI, 1e-2);
        assertEquals(11.14, AngleCalc.atan2(1, 5) * 180 / Math.PI, 1);
        assertEquals(180, AngleCalc.atan2(0, -5) * 180 / Math.PI, 1e-2);
        assertEquals(-90, AngleCalc.atan2(-5, 0) * 180 / Math.PI, 1e-2);

        assertEquals(90, Math.atan2(1, 0) * 180 / Math.PI, 1e-2);
        assertEquals(90, AngleCalc.atan2(1, 0) * 180 / Math.PI, 1e-2);
    }