matrix_access.inl 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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