Add Matrix4, implement TranslationMatrix()
This commit is contained in:
parent
9474153736
commit
b59b6d85c0
4 changed files with 37 additions and 10 deletions
|
@ -6,6 +6,7 @@ Import('env')
|
||||||
|
|
||||||
|
|
||||||
files = [
|
files = [
|
||||||
|
'matrix.cc',
|
||||||
'vector.cc',
|
'vector.cc',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
@ -13,14 +13,4 @@
|
||||||
#include "basics/types.hh"
|
#include "basics/types.hh"
|
||||||
#include "basics/vector.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__ */
|
#endif /* __BASICS_BASICS_HH__ */
|
||||||
|
|
29
src/basics/matrix.cc
Normal file
29
src/basics/matrix.cc
Normal 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 */
|
||||||
|
|
|
@ -65,6 +65,13 @@ protected:
|
||||||
typedef Matrix<4> Matrix4;
|
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. */
|
/** Scalar multiplication, scalar factor on the left. */
|
||||||
template<UInt N, UInt M>
|
template<UInt N, UInt M>
|
||||||
Matrix<N,M> operator*(const Double& lhs, const Matrix<N,M>& rhs);
|
Matrix<N,M> operator*(const Double& lhs, const Matrix<N,M>& rhs);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue