You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

47 lines
1.7 KiB

  1. ///////////////////////////////////////////////////////////////////////////////////////////////////
  2. // OpenGL Mathematics Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net)
  3. ///////////////////////////////////////////////////////////////////////////////////////////////////
  4. // Created : 2007-05-21
  5. // Updated : 2010-02-12
  6. // Licence : This source is under MIT License
  7. // File : gtx_component_wise.inl
  8. ///////////////////////////////////////////////////////////////////////////////////////////////////
  9. namespace glm
  10. {
  11. template <typename genType>
  12. GLM_FUNC_QUALIFIER typename genType::value_type compAdd(genType const & v)
  13. {
  14. typename genType::value_type result = typename genType::value_type(0);
  15. for(typename genType::size_type i = 0; i < v.length(); ++i)
  16. result += v[i];
  17. return result;
  18. }
  19. template <typename genType>
  20. GLM_FUNC_QUALIFIER typename genType::value_type compMul(genType const & v)
  21. {
  22. typename genType::value_type result = typename genType::value_type(1);
  23. for(typename genType::size_type i = 0; i < v.length(); ++i)
  24. result *= v[i];
  25. return result;
  26. }
  27. template <typename genType>
  28. GLM_FUNC_QUALIFIER typename genType::value_type compMin(genType const & v)
  29. {
  30. typename genType::value_type result = typename genType::value_type(v[0]);
  31. for(typename genType::size_type i = 1; i < v.length(); ++i)
  32. result = min(result, v[i]);
  33. return result;
  34. }
  35. template <typename genType>
  36. GLM_FUNC_QUALIFIER typename genType::value_type compMax(genType const & v)
  37. {
  38. typename genType::value_type result = typename genType::value_type(v[0]);
  39. for(typename genType::size_type i = 1; i < v.length(); ++i)
  40. result = max(result, v[i]);
  41. return result;
  42. }
  43. }//namespace glm