home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 10 / ioProg_10.iso / soft / optima / samples.z / grTransform.hpp < prev    next >
Encoding:
C/C++ Source or Header  |  1996-03-23  |  6.1 KB  |  183 lines

  1. #ifndef _GRTRANSFORM_H
  2. #define _GRTRANSFORM_H
  3.  
  4. #include "grvector.hpp"
  5.  
  6. // ---------- grBaseTransform --------- //
  7.  
  8. class grBaseTransform                   // IMPLEMENT BASIC TRANSFORMATION
  9. {
  10. public:
  11.  
  12.     grBaseTransform( void );            // DEFAULT CTOR -- IDENTITY
  13.  
  14.     grBaseTransform(                    // COPY CTOR
  15.         const grBaseTransform & o );    // -- transform to copy
  16.  
  17.     grBaseTransform & operator =(       // ASSIGNMENT OPERATOR
  18.         const grBaseTransform & o );    // -- transform to copy
  19.  
  20.     grPoint3 & apply(                   // APPLY TO A POINT
  21.         grPoint3 & point ) const;       // -- point to apply to
  22.  
  23.     grVector & apply(                   // APPLY TO A VECTOR
  24.         grVector & point ) const;       // -- vector to apply to
  25.  
  26.     void transpose( void );             // TAKE TRANSPOSE OF MATRIX
  27.  
  28.     grBaseTransform & operator *=(      // LEFT MULTIPLY BY TRANSFORM
  29.         const grBaseTransform & xfrm ); // -- transform to multiply by
  30.  
  31. protected:
  32.  
  33.     void copy(                          // COPY ANOTHER TRANSFORM
  34.         const grBaseTransform & xfrm ); // -- transform to copy
  35.  
  36. public:
  37.  
  38.     double * _rows[ 4 ];                // -- four row vectors
  39.  
  40. protected:
  41.  
  42.     double _storage[ 4 * 4 ];           // -- reserve storage for entries
  43. };
  44.  
  45.  
  46. // ----------- grChangeBase ----------- //
  47.  
  48. class grChangeBase                      // CHANGE COORDINATE SYSTEMS
  49.     : public grBaseTransform
  50. {
  51. public:
  52.  
  53.     grChangeBase(                       // CONSTRUCTOR
  54.         const grPoint3 & origin,        // -- origin of new coordinates
  55.         const grVector & ux,            // -- unit vector along new x
  56.         const grVector & uy,            // -- unit vector along new y
  57.         const grVector & uz );          // -- unit vector along new z
  58. };
  59.  
  60. // ------------ grRotation ------------ //
  61.  
  62. class grRotation                        // IMPLEMENT ROTATION
  63.     : public grBaseTransform
  64. {
  65. public:
  66.  
  67.     enum Axis {                         // COORDINATE AXIS FOR ROTATION
  68.         X, Y, Z,                        // -- three axes
  69.     };
  70.  
  71.     grRotation(                         // CONSTRUCTOR
  72.         const grPoint3 & origin,        // -- origin of rotation
  73.         const grVector & axis,          // -- axis of rotation
  74.         double amount );                // -- radians counter-clockwise
  75.  
  76.     grRotation(                         // CONSTRUCTOR
  77.         int axis,                       // -- coordinate axis
  78.         double amount );                // -- radians counter-clockwise
  79. };
  80.  
  81.  
  82. // -------------- grScale ------------- //
  83.  
  84. class grScale                           // IMPLEMENT SCALING
  85.     : public grBaseTransform
  86. {
  87. public:
  88.  
  89.     grScale(                            // CONSTRUCTOR
  90.         const grPoint3 & origin,        // -- scale origin
  91.         double sx, double sy, double sz ); // -- scale parameters
  92.  
  93.     grScale(                            // CONSTRUCTOR
  94.         const grPoint3 & origin,        // -- origin of scale
  95.         const grVector & direction,     // -- direction of scale
  96.         double amt );                   // -- amount to scale by
  97. };
  98.  
  99.  
  100. // ------------ grTranslate ----------- //
  101.  
  102. class grTranslate                       // IMPLEMENT TRANSLATION
  103.     : public grBaseTransform
  104. {
  105. public:
  106.  
  107.     grTranslate(                        // PERFORM GENERAL TRANSLATION
  108.         const grVector & translate );   // -- amount to translate by
  109. };
  110.  
  111.  
  112. // ----------- grPerspective ---------- //
  113.  
  114. class grPerspective                     // IMPLEMENT PERSPECTIVE PROJECTION
  115.     : public grBaseTransform
  116. {
  117. public:
  118.  
  119.     grPerspective(                      // CONSTRUCTOR
  120.         double fovy,                    // -- field of view, in abs degrees
  121.         double aspect,                  // -- aspect ratio(horz angle/vert)
  122.         double nearClip,                // -- distance to near clipping
  123.         double farClip );               // -- distance to far clipping
  124. };
  125.  
  126.  
  127. // ------------- grShearXY ------------ //
  128.  
  129. class grShearXY                         // IMPLEMENT (X,Y) SHEAR
  130.     : public grBaseTransform
  131. {
  132. public:
  133.  
  134.     grShearXY(                          // CONSTRUCTOR
  135.         double shx,                     // -- x parameter
  136.         double shy );                   // -- y parameter
  137. };
  138.  
  139. // ------------ grTransform ----------- //
  140.  
  141. class grTransform                       // REPRESENT GENERAL TRANSFORMATIONS
  142.     : public grBaseTransform
  143. {
  144. public:
  145.  
  146.     grTransform & operator =(           // ASSIGNMENT OPERATOR
  147.         const grBaseTransform & o )     // -- transform to copy
  148.     {
  149.         copy( o );
  150.         return *this;
  151.     }
  152.  
  153.  
  154.     grTransform & changeBase(           // PERFORM CHANGE OF BASIS
  155.         const grPoint3 & origin,        // -- origin of new coordinates
  156.         const grVector & ux,            // -- unit vector along new x
  157.         const grVector & uy,            // -- unit vector along new y
  158.         const grVector & uz );          // -- unit vector along new z
  159.  
  160.     grTransform & rotate(               // PERFORM GENERAL ROTATION
  161.         const grPoint3 & origin,        // -- origin of rotation
  162.         const grVector & axis,          // -- axis of rotation
  163.         double angle );                 // -- degrees counter-clockwise
  164.  
  165.     grTransform & rotate(               // PERFORM TRIVIAL ROTATION
  166.         int axis,                       // -- coordinate axis
  167.         double amount );                // -- radians counter-clockwise
  168.  
  169.     grTransform & scale(                // PERFORM SCALE RELATIVE TO COORD
  170.         const grPoint3 & origin,        // -- scale origin
  171.         double sx, double sy, double sz ); // -- scale parameters
  172.  
  173.     grTransform & scale(                // PERFORM SCALE RELATIVE TO DIRECTION
  174.         const grPoint3 & origin,        // -- origin of scale
  175.         const grVector & direction,     // -- direction of scale
  176.         double amt );                   // -- amount to scale by
  177.  
  178.     grTransform & translate(            // PERFORM GENERAL TRANSLATION
  179.         const grVector & translate );   // -- amount to translate by
  180. };
  181.  
  182. #endif // _GRTRANSFORM_H
  183.