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:
parent
13d7d90b87
commit
cd9530d21b
@ -1,30 +1,15 @@
|
|||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include "util/Matrix.h"
|
#include "util/Transform.h"
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
Matrix m = Matrix::identity();
|
Transform t;
|
||||||
m[0][3] = 2.0;
|
t.scale(3, 2, 1);
|
||||||
m[1][3] = -1.0;
|
t.translate(-1, 2, 3);
|
||||||
m[2][3] = 10.0;
|
cout << "t:" << endl << t.getMatrix();
|
||||||
|
|
||||||
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;
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -22,5 +22,9 @@ void Transform::rotate(double amt, double xv, double yv, double zv)
|
|||||||
|
|
||||||
void Transform::scale(double xs, double ys, double zs)
|
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;
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,7 @@ class Transform
|
|||||||
void translate(double x, double y, double z);
|
void translate(double x, double y, double z);
|
||||||
void rotate(double amt, double xv, double yv, double zv);
|
void rotate(double amt, double xv, double yv, double zv);
|
||||||
void scale(double xs, double ys, double zs);
|
void scale(double xs, double ys, double zs);
|
||||||
|
Matrix & getMatrix() { return m_matrix; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Matrix m_matrix;
|
Matrix m_matrix;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user