Here you can find the source of atan2(float y, float x)
static public float atan2(float y, float x)
//package com.java2s; //License from project: Open Source License public class Main { static public final float PI = 3.1415927f; /** Returns atan2 in radians, faster but less accurate than Math.atan2. Average error of 0.00231 radians (0.1323 degrees), * largest error of 0.00488 radians (0.2796 degrees). */ static public float atan2(float y, float x) { if (x == 0f) { if (y > 0f) return PI / 2; if (y == 0f) return 0f; return -PI / 2; }//from w w w . java2 s . com final float atan, z = y / x; if (Math.abs(z) < 1f) { atan = z / (1f + 0.28f * z * z); if (x < 0f) return atan + (y < 0f ? -PI : PI); return atan; } atan = PI / 2 - z / (z * z + 0.28f); return y < 0f ? atan - PI : atan; } }