ASinEstimate.h 1.0 KB

1234567891011121314151617181920212223242526272829303132
  1. // David Eberly, Geometric Tools, Redmond WA 98052
  2. // Copyright (c) 1998-2020
  3. // Distributed under the Boost Software License, Version 1.0.
  4. // https://www.boost.org/LICENSE_1_0.txt
  5. // https://www.geometrictools.com/License/Boost/LICENSE_1_0.txt
  6. // Version: 4.0.2019.08.13
  7. #pragma once
  8. #include <Mathematics/ACosEstimate.h>
  9. // Approximations to asin(x) of the form f(x) = pi/2 - sqrt(1-x)*p(x)
  10. // where the polynomial p(x) of degree D minimizes the quantity
  11. // maximum{|acos(x)/sqrt(1-x) - p(x)| : x in [0,1]} over all
  12. // polynomials of degree D. We use the identity asin(x) = pi/2 - acos(x).
  13. namespace WwiseGTE
  14. {
  15. template <typename Real>
  16. class ASinEstimate
  17. {
  18. public:
  19. // The input constraint is x in [0,1]. For example,
  20. // float x; // in [0,1]
  21. // float result = ASinEstimate<float>::Degree<3>(x);
  22. template <int D>
  23. inline static Real Degree(Real x)
  24. {
  25. return (Real)GTE_C_HALF_PI - ACosEstimate<Real>::Degree<D>(x);
  26. }
  27. };
  28. }