fast_square_root.hpp 2.9 KB

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