1 #ifndef TRANSFOMRATION
 2 #define TRANSFOMRATION
 3 
 4 #include "Matrix.hxx"
 5 
 6 class Transformation
 7 {
 8     /**
 9      * compute the inverse transformation for point and vector 
10      * nearly the same for both, just: translations have no effect on vectors
11      */
12     public: 
13         /**
14          * save transformations
15          */
16         Matrix* point;
17         Matrix* vector;
18 
19         /**
20          * create transformation matrix
21          */
22         Transformation()
23         { 
24             point  = new Matrix();
25             vector = new Matrix();
26         }
27     
28         /**
29          * tidy up
30          */
31         ~Transformation()
32         {
33             delete point;
34             delete vector;
35         };
36         
37         /**
38          * translation in dx, dy, dz
39          * inverse transformation: translation in -dx, -dy, -dz
40          */
41         void Translation(float dx, float dy, float dz)
42         {
43             point->Translation(-dx,-dy,-dz);
44         }
45         
46         /**
47          * rotation of theta around 'axis' 
48          * inverse transformation: rotation of -theta around 'axis'
49          */     
50         void Rotation(enum Matrix::Axis axis, float theta)
51         {
52             float angle = theta * (M_PI / 180.0);
53             point->Rotation (axis,-angle);
54             vector->Rotation(axis,-angle);
55         }
56         
57         /**
58          * scaling of sx, sy, sz
59          * inverse transformation: scaling of 1/sx, 1/sy and 1/sz
60          */
61         void Scaling(float sx, float sy, float sz)
62         {
63             sx = 1.0 / sx;
64             sy = 1.0 / sy;
65             sz = 1.0 / sz;
66             point->Scaling ( sx, sy, sz );
67             vector->Scaling( sx, sy, sz );
68         }
69         
70         /**
71          * shear
72          */
73         void Shear(float xy, float xz, float yz, float yx, float zx, float zy)
74         {
75             point->Shear ( -xy, -xz, -yz, -yx, -zx, -zy );
76             vector->Shear( -xy, -xz, -yz, -yx, -zx, -zy );
77         }
78 };
79 
80 #endif


syntax highlighted by Code2HTML, v. 0.9.1