MCPcopy Create free account
hub / github.com/GaijinEntertainment/daScript / v_atan2

Function v_atan2

include/vecmath/dag_vecMath_trig.h:325–336  ·  view source on GitHub ↗

calculates 4 in ~1.47x speed of win libc implementation for 1, with same precision

Source from the content-addressed store, hash-verified

323
324// calculates 4 in ~1.47x speed of win libc implementation for 1, with same precision
325VECTORCALL 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

Callers 5

ATan2Method · 0.85
vatan2Function · 0.85
v_euler_from_quatFunction · 0.85
v_dir_to_anglesFunction · 0.85
v_atan2_xFunction · 0.85

Calls 13

v_is_unsafe_divisorFunction · 0.85
v_atanFunction · 0.85
v_cast_vec4fFunction · 0.70
v_cmp_ltiFunction · 0.70
v_cast_vec4iFunction · 0.70
v_zeroiFunction · 0.70
v_cmp_eqFunction · 0.70
v_zeroFunction · 0.70
v_andFunction · 0.70
v_orFunction · 0.70
v_selFunction · 0.70
v_divFunction · 0.70

Tested by

no test coverage detected