#include #include #include using namespace std; #define N 3 class Vector3f { public: float polje[N]; Vector3f(); Vector3f(float, float, float); Vector3f(float a[3]); Vector3f(const Vector3f &); Vector3f& operator = (const Vector3f &temp){ if(this != &temp){ this->polje[0] = temp.polje[0]; this->polje[1] = temp.polje[1]; this->polje[2] = temp.polje[2]; } return *this; } //sale = sale + tena //sale += tena Vector3f& operator += (const Vector3f &temp){ this->polje[0] = this->polje[0] + temp.polje[0]; this->polje[1] = this->polje[1] + temp.polje[1]; this->polje[2] = this->polje[2] + temp.polje[2]; return *this; } Vector3f& operator -= (const Vector3f &); Vector3f& operator *= (float temp){ this->polje[0] = this->polje[0] * temp; return *this; } Vector3f& operator + (const Vector3f &temp) const{ // this upucuje na lijevu stranu operatora kojeg preopterecujemo // npr c= a + b, ako preopt +, this upucuje na a; Vector3f rez = *this; // kopiramo a u rez; rez += temp; // koristimo vec preoptereceni operator += return rez; } bool operator== (const Vector3f &temp) const{ bool nest; if ( this->polje[0] == temp.polje[0] && this->polje[1] == temp.polje[1] && this->polje[2] == temp.polje[2] ) nest = 1; else nest = 0; return nest; } bool operator !=(const Vector3f &temp) const{ bool nest; if (*this == temp) nest=0; else nest=1; return nest; } float& operator[](unsigned int temp){ return this->polje[temp]; } Vector3f& vec_produkt(Vector3f& temp){ Vector3f rez; rez.polje[0] = this->polje[1] * temp.polje[2] - temp.polje[1] * this->polje[2]; rez.polje[1] = this->polje[0] * temp.polje[2] - temp.polje[0] * this->polje[2]; rez.polje[2] = this->polje[0] * temp.polje[1] - temp.polje[0] * this->polje[1]; rez.ispisi(); return rez; } void ispisi(); }; class Matrix3f{ public: Vector3f matrica[N]; float a[N][N]; // prva dimenzija matrice float b[N][N]; // druga float c[N][N]; // treca Matrix3f(){ for(int i=0; ia[i][j] = temp.a[i][j]; this->b[i][j] = temp.b[i][j]; this->c[i][j] = temp.c[i][j]; } } return *this; } Matrix3f& operator += (const Matrix3f& temp){ if(this != &temp){ for(int i=0; ia[i][j] = this->a[i][j] + temp.a[i][j]; this->b[i][j] = this->b[i][j] + temp.b[i][j]; this->c[i][j] = this->c[i][j] + temp.c[i][j]; } } return *this; } } void ispisi(){ cout << "A dimenzija: " << endl; for(int i=0; i