diff options
author | Vegard Storheil Eriksen <zyp@jvnv.net> | 2010-04-08 15:27:31 +0200 |
---|---|---|
committer | Vegard Storheil Eriksen <zyp@jvnv.net> | 2010-04-08 15:27:31 +0200 |
commit | f281f316627b163489ecb39d837144142c9353f9 (patch) | |
tree | d104aa60e2e108b8cb80589f846f81770c62b859 /hcoord.cpp | |
parent | 834a37d1975b5baa609e93839947430d554a7f5f (diff) |
Added HVector and HMatrix classes.
Diffstat (limited to 'hcoord.cpp')
-rw-r--r-- | hcoord.cpp | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/hcoord.cpp b/hcoord.cpp new file mode 100644 index 0000000..86e9f26 --- /dev/null +++ b/hcoord.cpp @@ -0,0 +1,41 @@ +#include "hcoord.h" +#include <SDL/SDL_opengl.h> +#include <AR/ar.h> + +HVector::HVector() { + w = 1.0; +} + +HVector::HVector(double _x, double _y, double _z, double _w) { + x = _x; + y = _y; + z = _z; + w = _w; +} + +HMatrix::HMatrix() { + m[3][0] = m[3][1] = m[3][2] = 0; + m[3][3] = 1.0; +} + +HMatrix HMatrix::inverse() { + HMatrix res; + arUtilMatInv(m, res.m); + return res; +} + +HVector HMatrix::operator*(const HVector& vec) { + HVector res; + res.x = m[0][0] * vec.x + m[0][1] * vec.y + m[0][2] * vec.z + m[0][3]; + res.y = m[1][0] * vec.x + m[1][1] * vec.y + m[1][2] * vec.z + m[1][3]; + res.z = m[2][0] * vec.x + m[2][1] * vec.y + m[2][2] * vec.z + m[2][3]; + return res; +} + +HVector HMatrix::getTranslation() { + return HVector(m[0][3], m[1][3], m[2][3]); +} + +void HMatrix::glLoad() { + glLoadTransposeMatrixd((double*)m); +} |