Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2017
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. #include "Macierz3x3.hh"
  2.  
  3. Matrix::Matrix(const Vec3 &A, const Vec3 &B, const Vec3 &C)
  4. {
  5. Mat[0]=A;
  6. Mat[1]=B;
  7. Mat[2]=C;
  8. }
  9.  
  10. void Matrix::Swap(double &a, double &b)
  11. {
  12. double temp = a;
  13. a = b;
  14. b = temp;
  15. }
  16.  
  17. void Matrix::Trans()
  18. {
  19. for(int i=0; i<3; ++i)
  20. for(int j=i; j<3; ++j)
  21. Swap(Mat[i][j], Mat[j][i]);
  22. }
  23.  
  24. void Matrix::Set(const Vec3 &A, const Vec3 &B, const Vec3 &C)
  25. {
  26. Mat[0]=A;
  27. Mat[1]=B;
  28. Mat[2]=C;
  29. }
  30.  
  31. Matrix Matrix::operator*(const Matrix &Obj)
  32. {
  33. Matrix Ret;
  34. Trans();
  35. for(int i=0; i<3; ++i)
  36. for(int j=0; j<3; ++j)
  37. Ret[i][j]=Mat[j].MultiWithTrans(Obj[i]);
  38. Trans();
  39. return Ret;
  40. }
  41.  
  42. Vec3 Matrix::operator*(const Vec3 &Obj)
  43. {
  44. Vec3 Ret;
  45. Trans();
  46. for(int i=0; i<3; ++i) Ret[i]=Mat[i].MultiWithTrans(Obj);
  47. Trans();
  48. return Ret;
  49. }
  50.  
  51. Vec3& Matrix::operator[](int Index)
  52. {
  53. return Mat[Index];
  54. }
  55.  
  56. const Vec3& Matrix::operator[](int Index) const
  57. {
  58. return Mat[Index];
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement