fast_square_root.hpp 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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. #elif GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED)
  22. # pragma message("GLM: GLM_GTX_fast_square_root extension included")
  23. #endif
  24. namespace glm
  25. {
  26. /// @addtogroup gtx_fast_square_root
  27. /// @{
  28. /// Faster than the common sqrt function but less accurate.
  29. ///
  30. /// @see gtx_fast_square_root extension.
  31. template<typename genType>
  32. GLM_FUNC_DECL genType fastSqrt(genType x);
  33. /// Faster than the common sqrt function but less accurate.
  34. ///
  35. /// @see gtx_fast_square_root extension.
  36. template<length_t L, typename T, qualifier Q>
  37. GLM_FUNC_DECL vec<L, T, Q> fastSqrt(vec<L, T, Q> const& x);
  38. /// Faster than the common inversesqrt function but less accurate.
  39. ///
  40. /// @see gtx_fast_square_root extension.
  41. template<typename genType>
  42. GLM_FUNC_DECL genType fastInverseSqrt(genType x);
  43. /// Faster than the common inversesqrt function but less accurate.
  44. ///
  45. /// @see gtx_fast_square_root extension.
  46. template<length_t L, typename T, qualifier Q>
  47. GLM_FUNC_DECL vec<L, T, Q> fastInverseSqrt(vec<L, T, Q> const& x);
  48. /// Faster than the common length function but less accurate.
  49. ///
  50. /// @see gtx_fast_square_root extension.
  51. template<typename genType>
  52. GLM_FUNC_DECL genType fastLength(genType x);
  53. /// Faster than the common length function but less accurate.
  54. ///
  55. /// @see gtx_fast_square_root extension.
  56. template<length_t L, typename T, qualifier Q>
  57. GLM_FUNC_DECL T fastLength(vec<L, T, Q> const& x);
  58. /// Faster than the common distance function but less accurate.
  59. ///
  60. /// @see gtx_fast_square_root extension.
  61. template<typename genType>
  62. GLM_FUNC_DECL genType fastDistance(genType x, genType y);
  63. /// Faster than the common distance function but less accurate.
  64. ///
  65. /// @see gtx_fast_square_root extension.
  66. template<length_t L, typename T, qualifier Q>
  67. GLM_FUNC_DECL T fastDistance(vec<L, T, Q> const& x, vec<L, T, Q> const& y);
  68. /// Faster than the common normalize function but less accurate.
  69. ///
  70. /// @see gtx_fast_square_root extension.
  71. template<typename genType>
  72. GLM_FUNC_DECL genType fastNormalize(genType x);
  73. /// Faster than the common normalize function but less accurate.
  74. ///
  75. /// @see gtx_fast_square_root extension.
  76. template<length_t L, typename T, qualifier Q>
  77. GLM_FUNC_DECL vec<L, T, Q> fastNormalize(vec<L, T, Q> const& x);
  78. /// @}
  79. }// namespace glm
  80. #include "fast_square_root.inl"