00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #ifndef _TRANSFORM_H_
00028 #define _TRANSFORM_H_
00029
00030 #include <3D/Point.h>
00031 #include <3D/Matrix.h>
00032
00033 class Transform {
00034 public:
00035 Transform() {}
00036 Transform(const float m[16]) { setValue(m); }
00037 Transform(const double m[16]) { setValue(m); }
00038
00039 Point operator()(const Point& p) const {
00040 return Point(dot(basis[X], p) + origin[X],
00041 dot(basis[Y], p) + origin[Y],
00042 dot(basis[Z], p) + origin[Z]);
00043 }
00044
00045 const Matrix& getBasis() const { return basis; }
00046 const Point& getOrigin() const { return origin; }
00047
00048 void setValue(const float m[16]);
00049 void setValue(const double m[16]);
00050
00051 void setIdentity();
00052
00053 Transform& operator*=(const Transform& t);
00054
00055 void translate(const Vector& v);
00056 void rotate(const Quaternion& q);
00057 void scale(Scalar x, Scalar y, Scalar z);
00058
00059 void invert(const Transform& t);
00060 void mult(const Transform& t1, const Transform& t2);
00061 void multInverseLeft(const Transform& t1, const Transform& t2);
00062
00063 private:
00064 enum {
00065 IDENTITY = 0x00,
00066 TRANSLATION = 0x01,
00067 ROTATION = 0x02,
00068 SCALING = 0x04,
00069 LINEAR = ROTATION | SCALING,
00070 AFFINE = TRANSLATION | LINEAR
00071 };
00072
00073 Matrix basis;
00074 Point origin;
00075 unsigned int type;
00076 };
00077
00078 #endif