00001 /** 00002 * \file trans3d.h <mi32/trans3d.h> 00003 * \brief Definitions for 3-D transformation functions 00004 * 00005 * This header file requires C++ 00006 * 00007 * \if NODOC 00008 * $Id: trans3d.h_v 1.18 2004/06/14 16:36:01 mju Exp $ 00009 * 00010 * $Log: trans3d.h_v $ 00011 * Revision 1.18 2004/06/14 16:36:01 mju 00012 * Use const in findBestTrans3D. 00013 * 00014 * Revision 1.17 2004/01/08 18:18:52 scowan 00015 * Moved trans3d class to geom.dll. 00016 * 00017 * Revision 1.16 2003/09/15 13:49:56 fileserver!dwilliss 00018 * Doxygen 00019 * 00020 * Revision 1.15 2003/03/12 20:45:01 vdronov 00021 * added GetForward and GetInverse 00022 * 00023 * Revision 1.14 2002/11/27 21:40:02 vdronov 00024 * converrsion for FPOINT3D and FPOINT3DH added 00025 * 00026 * Revision 1.13 2002/11/20 22:02:44 vdronov 00027 * methods for DPOINT3DH added 00028 * 00029 * Revision 1.12 2000/10/04 20:36:38 msmith 00030 * Genitor documentation. 00031 * 00032 * Revision 1.11 2000/10/03 21:39:42 mju 00033 * Include string.h for memcpy() prototype. 00034 * 00035 * Revision 1.10 1999/08/23 15:33:02 dwilliss 00036 * Don't leave dangling commas in enums. Macintosh will hate you if you do. 00037 * 00038 * Revision 1.9 1999/08/18 15:07:43 mju 00039 * Comment out unused ApplyScale methods so will hopefully work on HP. 00040 * 00041 * Revision 1.8 1999/04/29 21:42:19 mju 00042 * Change TRANS3D to class. 00043 * 00044 * \endif 00045 **/ 00046 00047 #ifndef INC_MI32_TRANS3D_H 00048 #define INC_MI32_TRANS3D_H 00049 00050 #ifndef INC_MI32_STDDEFNS_H 00051 #include <mi32/stddefns.h> 00052 #endif 00053 00054 #ifdef GEOMDLL 00055 #define GEOMLIBEXPORT MI_DLLEXPORT 00056 #define GEOMLIBCLASSEXPORT MI_DLLCLASSEXPORT 00057 #else 00058 #define GEOMLIBEXPORT MI_DLLIMPORT 00059 #define GEOMLIBCLASSEXPORT MI_DLLCLASSIMPORT 00060 #endif 00061 00062 #ifndef GENERATING_DOXYGEN_OUTPUT 00063 struct CTRLPOINT3; 00064 struct CTRLPOINT3D; 00065 #endif // GENERATING_DOXYGEN_OUTPUT 00066 00067 //----------------------------------------------------------------------------- 00068 //! TRANS3D class 00069 //----------------------------------------------------------------------------- 00070 00071 class GEOMLIBCLASSEXPORT TRANS3D { 00072 public: 00073 00074 enum AXIS { 00075 AXIS_X = 0, 00076 AXIS_Y = 1, 00077 AXIS_Z = 2 00078 }; 00079 00080 enum PLANE { 00081 PLANE_XY = 0, 00082 PLANE_XZ = 1, 00083 PLANE_YZ = 2 00084 }; 00085 00086 //! Default constructor 00087 TRANS3D ( 00088 ); 00089 00090 //! Copy constructor 00091 TRANS3D ( 00092 const TRANS3D& rhs 00093 ); 00094 00095 //! Construct as combination of two transformations 00096 TRANS3D ( 00097 const TRANS3D& in1, 00098 const TRANS3D& in2 00099 ); 00100 00101 //! Destructor 00102 ~TRANS3D ( 00103 ); 00104 00105 //! Assignment 00106 TRANS3D& operator= ( 00107 const TRANS3D& rhs 00108 ); 00109 00110 //! Apply forward/inverse 3D matrices to transformation 00111 void ApplyMatrices ( 00112 const MAT4X4 fwd, //!< Forward transformation matrix 00113 const MAT4X4 inv //!< Inverse transformation matrix 00114 ); 00115 00116 //! Apply coordinate offset 00117 void ApplyOffset ( 00118 double xoffset, //!< X offset 00119 double yoffset, //!< Y offset 00120 double zoffset, //!< Z offset 00121 bool inverse = false //!< Apply in inverse direction 00122 ); 00123 00124 //! Apply coordinate offset 00125 void ApplyOffset ( 00126 const DPOINT3D& point, //!< Offset as X/Y/Z 00127 bool inverse = false //!< Apply in inverse direction 00128 ); 00129 00130 //! Apply rotation 00131 void ApplyRotation ( 00132 double angle, //!< Angle in radians 00133 AXIS axis, //!< Axis of rotation 00134 bool inverse = false //!< Apply in inverse direction 00135 ); 00136 00137 //! Apply scale 00138 void ApplyScale ( 00139 double xscale, //!< X scale 00140 double yscale, //!< Y scale 00141 double zscale, //!< Z scale 00142 bool inverse = false //!< Apply in inverse direction 00143 ); 00144 00145 //! Apply equal scale to all axes 00146 //! void ApplyScale ( 00147 //! double scale, // Scale 00148 //! bool inverse = false // Apply in inverse direction 00149 //! ) { 00150 //! ApplyScale(scale,scale,scale,inverse); 00151 //! return; 00152 //! } 00153 00154 //! Apply scale 00155 //! void ApplyScale ( 00156 //! const DPOINT3D& point, // X/Y/Z scale 00157 //! bool inverse = false // Apply in inverse direction 00158 //! ) { 00159 //! ApplyScale(point.x,point.y,point.z,inverse); 00160 //! return; 00161 //! } 00162 00163 //! Apply shear in given plane 00164 void ApplyShear ( 00165 double shear1, //!< First axis shear in radians 00166 double shear2, //!< Second axis shear in radians 00167 PLANE plane, //!< Shear plane 00168 bool inverse = false //!< Apply in inverse direction 00169 ); 00170 00171 //! Perform forward conversion on DPOINT3D array 00172 void ConvertForward ( 00173 const DPOINT3D *ipoints, //!< Source point array 00174 DPOINT3D *opoints, //!< Destination point array 00175 INT32 numpoints //!< Number of points to convert 00176 ) const; 00177 00178 //! Perform forward conversion on single 3D point 00179 DPOINT3D ConvertForward ( 00180 const DPOINT3D ipoint //!< Point to convert 00181 ) const; //! Returns converted point 00182 00183 //! Perform inverse conversion on DPOINT3D array 00184 void ConvertInverse ( 00185 const DPOINT3D *ipoints, //!< Source point array 00186 DPOINT3D *opoints, //!< Destination point array 00187 INT32 numpoints //!< Number of points to convert 00188 ) const; 00189 00190 //! Perform inverse conversion on single 3D point 00191 DPOINT3D ConvertInverse ( 00192 const DPOINT3D ipoint //!< Point to convert 00193 ) const; //! Returns converted point 00194 00195 //! Perform forward conversion on DPOINT3DH array 00196 void ConvertForward ( 00197 const DPOINT3DH *ipoints, //!< Source point array 00198 DPOINT3DH *opoints, //!< Destination point array 00199 INT32 numpoints //!< Number of points to convert 00200 ) const; 00201 00202 //! Perform forward conversion on single 3DH point 00203 DPOINT3DH ConvertForward ( 00204 const DPOINT3DH ipoint //!< Point to convert 00205 ) const; //! Returns converted point 00206 00207 //! Perform inverse conversion on DPOINT3DH array 00208 void ConvertInverse ( 00209 const DPOINT3DH *ipoints, //!< Source point array 00210 DPOINT3DH *opoints, //!< Destination point array 00211 INT32 numpoints //!< Number of points to convert 00212 ) const; 00213 00214 //! Perform inverse conversion on single 3DH point 00215 DPOINT3DH ConvertInverse ( 00216 const DPOINT3DH ipoint //!< Point to convert 00217 ) const; //! Returns converted point 00218 00219 //! Perform forward conversion on FPOINT3D array 00220 void ConvertForward ( 00221 const FPOINT3D *ipoints, //!< Source point array 00222 FPOINT3D *opoints, //!< Destination point array 00223 INT32 numpoints //!< Number of points to convert 00224 ) const; 00225 00226 //! Perform forward conversion on single 3D point 00227 FPOINT3D ConvertForward ( 00228 const FPOINT3D ipoint //!< Point to convert 00229 ) const; //! Returns converted point 00230 00231 //! Perform inverse conversion on FPOINT3D array 00232 void ConvertInverse ( 00233 const FPOINT3D *ipoints, //!< Source point array 00234 FPOINT3D *opoints, //!< Destination point array 00235 INT32 numpoints //!< Number of points to convert 00236 ) const; 00237 00238 //! Perform inverse conversion on single 3D point 00239 FPOINT3D ConvertInverse ( 00240 const FPOINT3D ipoint //!< Point to convert 00241 ) const; //! Returns converted point 00242 00243 //! Perform forward conversion on FPOINT3DH array 00244 void ConvertForward ( 00245 const FPOINT3DH *ipoints, //!< Source point array 00246 FPOINT3DH *opoints, //!< Destination point array 00247 INT32 numpoints //!< Number of points to convert 00248 ) const; 00249 00250 //! Perform forward conversion on single 3DH point 00251 FPOINT3DH ConvertForward ( 00252 const FPOINT3DH ipoint //!< Point to convert 00253 ) const; //! Returns converted point 00254 00255 //! Perform inverse conversion on FPOINT3DH array 00256 void ConvertInverse ( 00257 const FPOINT3DH *ipoints, //!< Source point array 00258 FPOINT3DH *opoints, //!< Destination point array 00259 INT32 numpoints //!< Number of points to convert 00260 ) const; 00261 00262 //! Perform inverse conversion on single 3DH point 00263 FPOINT3DH ConvertInverse ( 00264 const FPOINT3DH ipoint //!< Point to convert 00265 ) const; //! Returns converted point 00266 00267 //! Set transformation to identity 00268 void SetIdentity ( 00269 ); 00270 00271 const MAT4X4& GetForward ( 00272 ) const; 00273 00274 const MAT4X4& GetInverse ( 00275 ) const; 00276 00277 private: 00278 #ifndef GENERATING_DOXYGEN_OUTPUT 00279 MAT4X4 m_fwd; 00280 MAT4X4 m_inv; 00281 bool m_DoHomogeneous; //!< Need to perform homogenous transformation 00282 00283 //! Apply general matrix 00284 void ApplyMatrix ( 00285 const MAT4X4 mat, //!< Matrix to apply 00286 bool inverse //!< Inverse flag 00287 ); 00288 //! Check if need to do homogenous transformation 00289 void ChkNeedHomo (); 00290 #endif // GENERATING_DOXYGEN_OUTPUT 00291 }; 00292 00293 00294 //----------------------------------------------------------------------------- 00295 //! Function prototypes 00296 //----------------------------------------------------------------------------- 00297 00298 extern "C" { 00299 //! FindBestTrans3D - Find "best" 3-D affine transformation given set of control points 00300 GEOMLIBEXPORT int FindBestTrans3D ( 00301 int NumPoints, //!< Number of control points 00302 const CTRLPOINT3D* cp, //!< Set of control points 00303 MAT4X4 forward, //!< Transformation matrices 00304 MAT4X4 inverse 00305 ); 00306 00307 //! FindBestTrans3D3 - Find "best" 3-D affine transformation given a CTRLPOINT array 00308 GEOMLIBEXPORT int FindBestTrans3D3 ( 00309 int NumPoints, //!< Number of control points 00310 const CTRLPOINT3 *cp3, //!< Array of control points 00311 MAT4X4 forward, //!< Transformation matrices 00312 MAT4X4 inverse 00313 ); 00314 00315 //! Initialize 3-D affine transformation 00316 GEOMLIBEXPORT void trans3dinit ( 00317 MAT4X4, //!< Transformation matrices 00318 MAT4X4 00319 ); 00320 00321 //! Perform 3-D affine transformation on a point 00322 GEOMLIBEXPORT void trans3d ( 00323 double ix, //!< Input x 00324 double iy, //!< Input y 00325 double iz, //!< Input z 00326 MAT4X4 TransMat, //!< Transformation matrix 00327 double *ox, //!< Output x 00328 double *oy, //!< Output y 00329 double *oz //!< Output z 00330 ); 00331 00332 //! Apply offsets to a 3-D affine transformation 00333 GEOMLIBEXPORT void trans3dshift ( 00334 MAT4X4 m, //!< Matrices of transformation 00335 MAT4X4 n, 00336 double dx, //!< X offset 00337 double dy, //!< Y offset 00338 double dz //!< Z offset 00339 ); 00340 00341 //! Apply a scale change to a 3-D affine transformation 00342 GEOMLIBEXPORT void trans3dscale ( 00343 MAT4X4 m, //!< Matrices of transformation 00344 MAT4X4 n, 00345 double sx, //!< X scale 00346 double sy, //!< Y scale 00347 double sz //!< Z scale 00348 ); 00349 00350 //! Apply rotation to a 3-D affine transformation 00351 GEOMLIBEXPORT void trans3drot ( 00352 MAT4X4 m, //!< Matrices of transformation 00353 MAT4X4 n, 00354 double z_axis, //!< X axis 00355 double x_axis, //!< Y axis 00356 double y_axis //!< Z axis 00357 ); 00358 } 00359 00360 #endif 00361
1.3.8-20040913