home *** CD-ROM | disk | FTP | other *** search
- #ifndef _GRTRANSFORM_H
- #define _GRTRANSFORM_H
-
- #include "grvector.hpp"
-
- // ---------- grBaseTransform --------- //
-
- class grBaseTransform // IMPLEMENT BASIC TRANSFORMATION
- {
- public:
-
- grBaseTransform( void ); // DEFAULT CTOR -- IDENTITY
-
- grBaseTransform( // COPY CTOR
- const grBaseTransform & o ); // -- transform to copy
-
- grBaseTransform & operator =( // ASSIGNMENT OPERATOR
- const grBaseTransform & o ); // -- transform to copy
-
- grPoint3 & apply( // APPLY TO A POINT
- grPoint3 & point ) const; // -- point to apply to
-
- grVector & apply( // APPLY TO A VECTOR
- grVector & point ) const; // -- vector to apply to
-
- void transpose( void ); // TAKE TRANSPOSE OF MATRIX
-
- grBaseTransform & operator *=( // LEFT MULTIPLY BY TRANSFORM
- const grBaseTransform & xfrm ); // -- transform to multiply by
-
- protected:
-
- void copy( // COPY ANOTHER TRANSFORM
- const grBaseTransform & xfrm ); // -- transform to copy
-
- public:
-
- double * _rows[ 4 ]; // -- four row vectors
-
- protected:
-
- double _storage[ 4 * 4 ]; // -- reserve storage for entries
- };
-
-
- // ----------- grChangeBase ----------- //
-
- class grChangeBase // CHANGE COORDINATE SYSTEMS
- : public grBaseTransform
- {
- public:
-
- grChangeBase( // CONSTRUCTOR
- const grPoint3 & origin, // -- origin of new coordinates
- const grVector & ux, // -- unit vector along new x
- const grVector & uy, // -- unit vector along new y
- const grVector & uz ); // -- unit vector along new z
- };
-
- // ------------ grRotation ------------ //
-
- class grRotation // IMPLEMENT ROTATION
- : public grBaseTransform
- {
- public:
-
- enum Axis { // COORDINATE AXIS FOR ROTATION
- X, Y, Z, // -- three axes
- };
-
- grRotation( // CONSTRUCTOR
- const grPoint3 & origin, // -- origin of rotation
- const grVector & axis, // -- axis of rotation
- double amount ); // -- radians counter-clockwise
-
- grRotation( // CONSTRUCTOR
- int axis, // -- coordinate axis
- double amount ); // -- radians counter-clockwise
- };
-
-
- // -------------- grScale ------------- //
-
- class grScale // IMPLEMENT SCALING
- : public grBaseTransform
- {
- public:
-
- grScale( // CONSTRUCTOR
- const grPoint3 & origin, // -- scale origin
- double sx, double sy, double sz ); // -- scale parameters
-
- grScale( // CONSTRUCTOR
- const grPoint3 & origin, // -- origin of scale
- const grVector & direction, // -- direction of scale
- double amt ); // -- amount to scale by
- };
-
-
- // ------------ grTranslate ----------- //
-
- class grTranslate // IMPLEMENT TRANSLATION
- : public grBaseTransform
- {
- public:
-
- grTranslate( // PERFORM GENERAL TRANSLATION
- const grVector & translate ); // -- amount to translate by
- };
-
-
- // ----------- grPerspective ---------- //
-
- class grPerspective // IMPLEMENT PERSPECTIVE PROJECTION
- : public grBaseTransform
- {
- public:
-
- grPerspective( // CONSTRUCTOR
- double fovy, // -- field of view, in abs degrees
- double aspect, // -- aspect ratio(horz angle/vert)
- double nearClip, // -- distance to near clipping
- double farClip ); // -- distance to far clipping
- };
-
-
- // ------------- grShearXY ------------ //
-
- class grShearXY // IMPLEMENT (X,Y) SHEAR
- : public grBaseTransform
- {
- public:
-
- grShearXY( // CONSTRUCTOR
- double shx, // -- x parameter
- double shy ); // -- y parameter
- };
-
- // ------------ grTransform ----------- //
-
- class grTransform // REPRESENT GENERAL TRANSFORMATIONS
- : public grBaseTransform
- {
- public:
-
- grTransform & operator =( // ASSIGNMENT OPERATOR
- const grBaseTransform & o ) // -- transform to copy
- {
- copy( o );
- return *this;
- }
-
-
- grTransform & changeBase( // PERFORM CHANGE OF BASIS
- const grPoint3 & origin, // -- origin of new coordinates
- const grVector & ux, // -- unit vector along new x
- const grVector & uy, // -- unit vector along new y
- const grVector & uz ); // -- unit vector along new z
-
- grTransform & rotate( // PERFORM GENERAL ROTATION
- const grPoint3 & origin, // -- origin of rotation
- const grVector & axis, // -- axis of rotation
- double angle ); // -- degrees counter-clockwise
-
- grTransform & rotate( // PERFORM TRIVIAL ROTATION
- int axis, // -- coordinate axis
- double amount ); // -- radians counter-clockwise
-
- grTransform & scale( // PERFORM SCALE RELATIVE TO COORD
- const grPoint3 & origin, // -- scale origin
- double sx, double sy, double sz ); // -- scale parameters
-
- grTransform & scale( // PERFORM SCALE RELATIVE TO DIRECTION
- const grPoint3 & origin, // -- origin of scale
- const grVector & direction, // -- direction of scale
- double amt ); // -- amount to scale by
-
- grTransform & translate( // PERFORM GENERAL TRANSLATION
- const grVector & translate ); // -- amount to translate by
- };
-
- #endif // _GRTRANSFORM_H
-