filled in scale() transformation in util/Transform

git-svn-id: svn://anubis/fart/trunk@28 7f9b0f55-74a9-4bce-be96-3c2cd072584d
This commit is contained in:
Josh Holtrop 2009-01-22 20:36:05 +00:00
parent 13d7d90b87
commit cd9530d21b
3 changed files with 11 additions and 21 deletions

View File

@ -1,30 +1,15 @@
#include <iostream>
#include <cassert>
#include "util/Matrix.h"
#include "util/Transform.h"
using namespace std;
int main()
{
Matrix m = Matrix::identity();
m[0][3] = 2.0;
m[1][3] = -1.0;
m[2][3] = 10.0;
cout << "m:" << endl << m;
Matrix i = m.getInverse();
cout << "i:" << endl << i;
Matrix mult = m * i;
cout << "mult:" << endl << mult;
m *= m;
cout << "m^2:" << endl << m;
m *= m;
cout << "m^4:" << endl << m;
Transform t;
t.scale(3, 2, 1);
t.translate(-1, 2, 3);
cout << "t:" << endl << t.getMatrix();
return 0;
}

View File

@ -22,5 +22,9 @@ void Transform::rotate(double amt, double xv, double yv, double zv)
void Transform::scale(double xs, double ys, double zs)
{
/* TODO: fill in */
Matrix t = Matrix::identity();
t[0][0] = xs;
t[1][1] = ys;
t[2][2] = zs;
m_matrix *= t;
}

View File

@ -12,6 +12,7 @@ class Transform
void translate(double x, double y, double z);
void rotate(double amt, double xv, double yv, double zv);
void scale(double xs, double ys, double zs);
Matrix & getMatrix() { return m_matrix; }
protected:
Matrix m_matrix;