calculates 4 in ~1.47x speed of win libc implementation for 1, with same precision
| 323 | |
| 324 | // calculates 4 in ~1.47x speed of win libc implementation for 1, with same precision |
| 325 | VECTORCALL VECMATH_FINLINE vec4f v_atan2(vec4f y, vec4f x) |
| 326 | { |
| 327 | vec4f maskXeq0 = v_is_unsafe_divisor(x); |
| 328 | vec4f maskXlt0 = v_cast_vec4f(v_cmp_lti(v_cast_vec4i(x), v_zeroi())); |
| 329 | vec4f maskYeq0 = v_cmp_eq(y, v_zero()); |
| 330 | vec4f signY = v_and(y, V_CI_SIGN_MASK); |
| 331 | vec4f zeroXres = v_or(signY, v_sel(V_C_HALFPI, v_and(V_C_PI, maskXlt0), maskYeq0)); |
| 332 | vec4f offs = v_or(signY, v_and(V_C_PI, maskXlt0)); |
| 333 | vec4f atan = v_atan(v_div(y, x)); |
| 334 | atan = v_add(atan, offs); |
| 335 | return v_sel(atan, zeroXres, maskXeq0); |
| 336 | } |
| 337 | |
| 338 | // fast approx atan2 version. |error| is < 0.0004 |
| 339 | // calculates 4 in ~1.47x+ (untested, faster than v_atan2) speed of win libc implementation for 1 |
no test coverage detected