fast_square_root.hpp 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /// @ref gtx_fast_square_root
  2. /// @file glm/gtx/fast_square_root.hpp
  3. ///
  4. /// @see core (dependence)
  5. ///
  6. /// @defgroup gtx_fast_square_root GLM_GTX_fast_square_root
  7. /// @ingroup gtx
  8. ///
  9. /// Include <glm/gtx/fast_square_root.hpp> to use the features of this extension.
  10. ///
  11. /// Fast but less accurate implementations of square root based functions.
  12. /// - Sqrt optimisation based on Newton's method,
  13. /// www.gamedev.net/community/forums/topic.asp?topic id=139956
  14. #pragma once
  15. // Dependency:
  16. #include "../common.hpp"
  17. #include "../exponential.hpp"
  18. #include "../geometric.hpp"
  19. #ifndef GLM_ENABLE_EXPERIMENTAL
  20. # error "GLM: GLM_GTX_fast_square_root is an experimental extension and may change in the future. Use #define GLM_ENABLE_EXPERIMENTAL before including it, if you really want to use it."
  21. #endif
  22. #if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED)
  23. # pragma message("GLM: GLM_GTX_fast_square_root extension included")
  24. #endif
  25. namespace glm
  26. {
  27. /// @addtogroup gtx_fast_square_root
  28. /// @{
  29. /// Faster than the common sqrt function but less accurate.
  30. ///
  31. /// @see gtx_fast_square_root extension.
  32. template<typename genType>
  33. GLM_FUNC_DECL genType fastSqrt(genType x);
  34. /// Faster than the common sqrt function but less accurate.
  35. ///
  36. /// @see gtx_fast_square_root extension.
  37. template<length_t L, typename T, qualifier Q>
  38. GLM_FUNC_DECL vec<L, T, Q> fastSqrt(vec<L, T, Q> const& x);
  39. /// Faster than the common inversesqrt function but less accurate.
  40. ///
  41. /// @see gtx_fast_square_root extension.
  42. template<typename genType>
  43. GLM_FUNC_DECL genType fastInverseSqrt(genType x);
  44. /// Faster than the common inversesqrt function but less accurate.
  45. ///
  46. /// @see gtx_fast_square_root extension.
  47. template<length_t L, typename T, qualifier Q>
  48. GLM_FUNC_DECL vec<L, T, Q> fastInverseSqrt(vec<L, T, Q> const& x);
  49. /// Faster than the common length function but less accurate.
  50. ///
  51. /// @see gtx_fast_square_root extension.
  52. template<typename genType>
  53. GLM_FUNC_DECL genType fastLength(genType x);
  54. /// Faster than the common length function but less accurate.
  55. ///
  56. /// @see gtx_fast_square_root extension.
  57. template<length_t L, typename T, qualifier Q>
  58. GLM_FUNC_DECL T fastLength(vec<L, T, Q> const& x);
  59. /// Faster than the common distance function but less accurate.
  60. ///
  61. /// @see gtx_fast_square_root extension.
  62. template<typename genType>
  63. GLM_FUNC_DECL genType fastDistance(genType x, genType y);
  64. /// Faster than the common distance function but less accurate.
  65. ///
  66. /// @see gtx_fast_square_root extension.
  67. template<length_t L, typename T, qualifier Q>
  68. GLM_FUNC_DECL T fastDistance(vec<L, T, Q> const& x, vec<L, T, Q> const& y);
  69. /// Faster than the common normalize function but less accurate.
  70. ///
  71. /// @see gtx_fast_square_root extension.
  72. template<typename genType>
  73. GLM_FUNC_DECL genType fastNormalize(genType const& x);
  74. /// @}
  75. }// namespace glm
  76. #include "fast_square_root.inl"