Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "Macierz3x3.hh"
- Matrix::Matrix(const Vec3 &A, const Vec3 &B, const Vec3 &C)
- {
- Mat[0]=A;
- Mat[1]=B;
- Mat[2]=C;
- }
- void Matrix::Swap(double &a, double &b)
- {
- double temp = a;
- a = b;
- b = temp;
- }
- void Matrix::Trans()
- {
- for(int i=0; i<3; ++i)
- for(int j=i; j<3; ++j)
- Swap(Mat[i][j], Mat[j][i]);
- }
- void Matrix::Set(const Vec3 &A, const Vec3 &B, const Vec3 &C)
- {
- Mat[0]=A;
- Mat[1]=B;
- Mat[2]=C;
- }
- Matrix Matrix::operator*(const Matrix &Obj)
- {
- Matrix Ret;
- Trans();
- for(int i=0; i<3; ++i)
- for(int j=0; j<3; ++j)
- Ret[i][j]=Mat[j].MultiWithTrans(Obj[i]);
- Trans();
- return Ret;
- }
- Vec3 Matrix::operator*(const Vec3 &Obj)
- {
- Vec3 Ret;
- Trans();
- for(int i=0; i<3; ++i) Ret[i]=Mat[i].MultiWithTrans(Obj);
- Trans();
- return Ret;
- }
- Vec3& Matrix::operator[](int Index)
- {
- return Mat[Index];
- }
- const Vec3& Matrix::operator[](int Index) const
- {
- return Mat[Index];
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement