Add Matrix4, implement TranslationMatrix()

This commit is contained in:
Eryn Wells 2014-08-08 22:14:20 -07:00
parent 9474153736
commit b59b6d85c0
4 changed files with 37 additions and 10 deletions

View file

@ -6,6 +6,7 @@ Import('env')
files = [
'matrix.cc',
'vector.cc',
]

View file

@ -13,14 +13,4 @@
#include "basics/types.hh"
#include "basics/vector.hh"
namespace charles {
namespace basics {
/** A 4-square matrix */
typedef Matrix<4> Matrix4;
} /* namespace basics */
} /* namespace charles */
#endif /* __BASICS_BASICS_HH__ */

29
src/basics/matrix.cc Normal file
View file

@ -0,0 +1,29 @@
/* matrix.cc
* vim: set tw=80:
* Eryn Wells <eryn@erynwells.me>
*/
#include "matrix.hh"
namespace charles {
namespace basics {
/*
* charles::basics::TranslationMatrix --
*/
Matrix4
TranslationMatrix(const Double& x,
const Double& y,
const Double& z)
{
Matrix4 m = Matrix4::Identity();
m(0, 3) = x;
m(1, 3) = y;
m(2, 3) = z;
return m;
}
} /* namespace mespace */
} /* namespace charles */

View file

@ -65,6 +65,13 @@ protected:
typedef Matrix<4> Matrix4;
/**
* Create a translation matrix that will translate a vector to the given
* coordinates.
*/
static Matrix4 TranslationMatrix(const Double& x, const Double& y, const Double& z);
/** Scalar multiplication, scalar factor on the left. */
template<UInt N, UInt M>
Matrix<N,M> operator*(const Double& lhs, const Matrix<N,M>& rhs);