matrix_access.inl 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /// @ref gtc_matrix_access
  2. namespace glm
  3. {
  4. template<typename genType>
  5. GLM_FUNC_QUALIFIER genType row
  6. (
  7. genType const& m,
  8. length_t index,
  9. typename genType::row_type const& x
  10. )
  11. {
  12. assert(index >= 0 && index < m[0].length());
  13. genType Result = m;
  14. for(length_t i = 0; i < m.length(); ++i)
  15. Result[i][index] = x[i];
  16. return Result;
  17. }
  18. template<typename genType>
  19. GLM_FUNC_QUALIFIER typename genType::row_type row
  20. (
  21. genType const& m,
  22. length_t index
  23. )
  24. {
  25. assert(index >= 0 && index < m[0].length());
  26. typename genType::row_type Result(0);
  27. for(length_t i = 0; i < m.length(); ++i)
  28. Result[i] = m[i][index];
  29. return Result;
  30. }
  31. template<typename genType>
  32. GLM_FUNC_QUALIFIER genType column
  33. (
  34. genType const& m,
  35. length_t index,
  36. typename genType::col_type const& x
  37. )
  38. {
  39. assert(index >= 0 && index < m.length());
  40. genType Result = m;
  41. Result[index] = x;
  42. return Result;
  43. }
  44. template<typename genType>
  45. GLM_FUNC_QUALIFIER typename genType::col_type column
  46. (
  47. genType const& m,
  48. length_t index
  49. )
  50. {
  51. assert(index >= 0 && index < m.length());
  52. return m[index];
  53. }
  54. }//namespace glm