added operator*=() to util/Matrix
git-svn-id: svn://anubis/fart/trunk@27 7f9b0f55-74a9-4bce-be96-3c2cd072584d
This commit is contained in:
parent
1454fe8c2e
commit
13d7d90b87
@ -20,5 +20,11 @@ int main()
|
|||||||
Matrix mult = m * i;
|
Matrix mult = m * i;
|
||||||
cout << "mult:" << endl << mult;
|
cout << "mult:" << endl << mult;
|
||||||
|
|
||||||
|
m *= m;
|
||||||
|
cout << "m^2:" << endl << m;
|
||||||
|
|
||||||
|
m *= m;
|
||||||
|
cout << "m^4:" << endl << m;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -191,6 +191,13 @@ Matrix Matrix::getInverse()
|
|||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Matrix & Matrix::operator*=(const Matrix & other)
|
||||||
|
{
|
||||||
|
Matrix temp = (*this) * other;
|
||||||
|
(*this) = temp;
|
||||||
|
return (*this);
|
||||||
|
}
|
||||||
|
|
||||||
Matrix operator*(const Matrix & m1, const Matrix & m2)
|
Matrix operator*(const Matrix & m1, const Matrix & m2)
|
||||||
{
|
{
|
||||||
Matrix res;
|
Matrix res;
|
||||||
|
@ -15,6 +15,7 @@ class Matrix
|
|||||||
static Matrix identity();
|
static Matrix identity();
|
||||||
double determinant();
|
double determinant();
|
||||||
Matrix getInverse();
|
Matrix getInverse();
|
||||||
|
Matrix & operator*=(const Matrix & other);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
double m_matrix[4][4];
|
double m_matrix[4][4];
|
||||||
|
@ -8,7 +8,11 @@ Transform::Transform()
|
|||||||
|
|
||||||
void Transform::translate(double x, double y, double z)
|
void Transform::translate(double x, double y, double z)
|
||||||
{
|
{
|
||||||
/* TODO: fill in */
|
Matrix t = Matrix::identity();
|
||||||
|
t[0][3] = x;
|
||||||
|
t[1][3] = y;
|
||||||
|
t[2][3] = z;
|
||||||
|
m_matrix *= t;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Transform::rotate(double amt, double xv, double yv, double zv)
|
void Transform::rotate(double amt, double xv, double yv, double zv)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user