operator<< for pretty-printing an entire Matrix4

This commit is contained in:
Eryn Wells 2014-08-16 16:57:58 -07:00
parent 09c5e29f63
commit 10195c607c
2 changed files with 32 additions and 1 deletions

View file

@ -346,6 +346,35 @@ Inverse(Matrix4 m)
}
/*
* charles::basics::operator<< --
*/
std::ostream&
operator<<(std::ostream &ost,
const Matrix4 &m)
{
ost << "[";
for (UInt i = 0; i < 4; i++) {
if (i != 0) {
ost << " ";
}
ost << "[";
for (UInt j = 0; j < 4; j++) {
ost << m(i,j);
if (j < 3) {
ost << " ";
}
}
ost << "]";
if (i < 3) {
ost << "\n";
}
}
ost << "]";
return ost;
}
} /* namespace mespace */
} /* namespace charles */

View file

@ -93,13 +93,15 @@ protected:
/** Scalar multiplication, scalar factor on the left. */
Matrix4 operator*(Double lhs, const Matrix4 &rhs);
/** Transpose the given matrix. */
Matrix4 Transpose(Matrix4 m);
/** Invert the given matrix. */
Matrix4 Inverse(Matrix4 m);
std::ostream& operator<<(std::ostream &ost, const Matrix4 &m);
} /* namespace basics */
} /* namespace charles */