added transformation operations to util/Transform
git-svn-id: svn://anubis/fart/trunk@31 7f9b0f55-74a9-4bce-be96-3c2cd072584d
This commit is contained in:
parent
2deee25004
commit
277252ef77
@ -53,3 +53,21 @@ void Transform::scale(double xs, double ys, double zs)
|
|||||||
t[2][2] = zs;
|
t[2][2] = zs;
|
||||||
m_matrix *= t;
|
m_matrix *= t;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Vector operator*(Transform & t, const Vector & v)
|
||||||
|
{
|
||||||
|
return t.getMatrix() * v;
|
||||||
|
}
|
||||||
|
|
||||||
|
Vector operator%(Transform & t, const Vector & v)
|
||||||
|
{
|
||||||
|
return t.getMatrix() % v;
|
||||||
|
}
|
||||||
|
|
||||||
|
Ray operator*(Transform & t, const Ray & r)
|
||||||
|
{
|
||||||
|
Vector newPosition = t.getMatrix() * r.getOrigin();
|
||||||
|
Vector newDirection = t.getMatrix() % r.getDirection();
|
||||||
|
Ray res(newPosition, newDirection);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
@ -3,6 +3,8 @@
|
|||||||
#define TRANSFORM_H TRANSFORM_H
|
#define TRANSFORM_H TRANSFORM_H
|
||||||
|
|
||||||
#include "Matrix.h"
|
#include "Matrix.h"
|
||||||
|
#include "Ray.h"
|
||||||
|
#include "Vector.h"
|
||||||
#include <stack>
|
#include <stack>
|
||||||
|
|
||||||
class Transform
|
class Transform
|
||||||
@ -18,5 +20,9 @@ class Transform
|
|||||||
Matrix m_matrix;
|
Matrix m_matrix;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Vector operator*(Transform & t, const Vector & v);
|
||||||
|
Vector operator%(Transform & t, const Vector & v);
|
||||||
|
Ray operator*(Transform & t, const Ray & r);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user