functions.inl 773 B

123456789101112131415161718192021222324252627282930
  1. /// @ref gtx_functions
  2. #include "../exponential.hpp"
  3. namespace glm
  4. {
  5. template<typename T>
  6. GLM_FUNC_QUALIFIER T gauss
  7. (
  8. T x,
  9. T ExpectedValue,
  10. T StandardDeviation
  11. )
  12. {
  13. return exp(-((x - ExpectedValue) * (x - ExpectedValue)) / (static_cast<T>(2) * StandardDeviation * StandardDeviation)) / (StandardDeviation * sqrt(static_cast<T>(6.28318530717958647692528676655900576)));
  14. }
  15. template<typename T, qualifier Q>
  16. GLM_FUNC_QUALIFIER T gauss
  17. (
  18. vec<2, T, Q> const& Coord,
  19. vec<2, T, Q> const& ExpectedValue,
  20. vec<2, T, Q> const& StandardDeviation
  21. )
  22. {
  23. vec<2, T, Q> const Squared = ((Coord - ExpectedValue) * (Coord - ExpectedValue)) / (static_cast<T>(2) * StandardDeviation * StandardDeviation);
  24. return exp(-(Squared.x + Squared.y));
  25. }
  26. }//namespace glm