MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / atan2_est

Method atan2_est

Source/ThirdParty/basis_universal/encoder/cppspmd_math.h:394–418  ·  view source on GitHub ↗

Math from: http://developer.download.nvidia.com/cg/atan2.html TODO: Needs more validation, parameter checking.

Source from the content-addressed store, hash-verified

392// Math from: http://developer.download.nvidia.com/cg/atan2.html
393// TODO: Needs more validation, parameter checking.
394CPPSPMD_FORCE_INLINE vfloat spmd_kernel::atan2_est(vfloat y, vfloat x)
395{
396 vfloat t1 = abs(y);
397 vfloat t3 = abs(x);
398
399 vfloat t0 = max(t3, t1);
400 store_all(t1, min(t3, t1));
401
402 store_all(t3, t1 / t0);
403
404 vfloat t4 = t3 * t3;
405 store_all(t0, vfma(-0.013480470f, t4, 0.057477314f));
406 store_all(t0, vfms(t0, t4, 0.121239071f));
407 store_all(t0, vfma(t0, t4, 0.195635925f));
408 store_all(t0, vfms(t0, t4, 0.332994597f));
409 store_all(t0, vfma(t0, t4, 0.999995630f));
410 store_all(t3, t0 * t3);
411
412 store_all(t3, spmd_ternaryf(abs(y) > abs(x), vfloat(1.570796327f) - t3, t3));
413
414 store_all(t3, spmd_ternaryf(x < 0.0f, vfloat(3.141592654f) - t3, t3));
415 store_all(t3, spmd_ternaryf(y < 0.0f, -t3, t3));
416
417 return t3;
418}
419
420/*
421 clang 9.0.0 for win /fp:precise release

Callers

nothing calls this directly

Calls 7

vfmaFunction · 0.85
vfmsFunction · 0.85
spmd_ternaryfFunction · 0.85
vfloatClass · 0.85
absFunction · 0.70
maxFunction · 0.70
minFunction · 0.70

Tested by

no test coverage detected