Home Page Toolkit Overview Using GML User Input Services Finger Tracker Calibrator Frame Grabber Service protocol Obtaining GML Installing GML Licence Developer Documentation Tcl/Tk API The GML Canvas Image processing Tcl Scripts Library List of Classes List of Files C/C++ API List of Classes List of Files |
gml_GRItemTransfo.h00001 // gml_GRItemTransfo.h -- 00002 // 00003 // Declares the "gml_TGRItemTransfo" class. A gml_TGRItemTransfo object is a 00004 // geomtric transformation. 00005 // 00006 // Copyright (c) 2003 CLIPS-IMAG 00007 // 00008 // See the file "gml_LicenseTerms.txt" for information on usage and redistribution 00009 // of this file, and for a DISCLAIMER OF ALL WARRANTIES. 00010 // 00011 // Created on November 19, 2003 (FB). 00012 00013 #ifndef __GML_GRITEMTRANSFO__ 00014 #define __GML_GRITEMTRANSFO__ 00015 00016 #include <float.h> 00017 00018 #include "gml/base/gml_Errors.h" 00019 00020 #include "gml/base/gml_Alloc.h" 00021 #include "gml/math/gml_ElMat4.h" 00022 00023 00024 // gml_TGRItemParam -- 00025 // 00026 // The type of geometric parameters (for tranformations or shapes). 00027 00028 typedef float gml_TGRItemParam; 00029 00030 00031 00032 00033 // gml_TGRItemTransfo -- 00034 00035 class gml_TGRItemTransfo 00036 { 00037 public: 00038 00039 // Init -- 00040 // 00041 // Initialize the item transformation. the transformation remains undefined, 00042 // in particular, it should not be assumed as "identity". 00043 00044 gml_TError Init (); 00045 00046 // Dispose -- 00047 // 00048 // Releases the resources allocated to this object. 00049 00050 void Dispose () {} 00051 00052 00053 00054 // Matrix -- 00055 // 00056 // Returns a pointer to the 16 (4x4) matrix parameters. Parameters are stored by 00057 // column first, then row. 00058 // The returned data is owned by the object and must not me modified. 00059 inline 00060 gml_TGRItemParam* Matrix (); 00061 00062 // Stdv -- 00063 // 00064 // Returns a vector of the 5 parameters that describe the standard transformation 00065 // corresponding to this item transformation. The parameters are: 00066 // x-translation, y-translation, rotation, x-scaling, and y-scaling. 00067 // The returned vector is owned by the object and must not be modified. 00068 inline 00069 gml_TGRItemParam* Stdv (); 00070 00071 // GetStd -- 00072 // 00073 // Same as "Stdv" excepted that the parameters are returned in the provided 00074 // variables (owned by the caller). 00075 inline 00076 void GetStd (gml_TGRItemParam& tx, 00077 gml_TGRItemParam& ty, 00078 gml_TGRItemParam& r, 00079 gml_TGRItemParam& sx, 00080 gml_TGRItemParam& sy); 00081 00082 // SetToIdentity -- 00083 // 00084 // Sets the item transformation to identity. 00085 00086 void SetToIdentity (); 00087 00088 // CopyTo -- 00089 // 00090 // Copy this item transformation parameters to another one. 00091 inline 00092 void CopyTo (gml_TGRItemTransfo* t); 00093 00094 // SetFromMult -- 00095 // 00096 // Set this item transformation parameters as the result of the multiplication 00097 // of two transformations <t1> and <t2>. This object must not be <t1> nor <t2>. 00098 inline 00099 void SetFromMult (gml_TGRItemTransfo* t1, gml_TGRItemTransfo* t2); 00100 00101 // SetFromInverse -- 00102 inline 00103 void SetFromInverse (gml_TGRItemTransfo* t); 00104 00105 // SetFromStdv -- 00106 // 00107 // Sets this item transformation parameters according to the provided 00108 // standard transformation vector <stdTransfo>. 00109 inline 00110 void SetFromStdv (gml_TGRItemParam* stdTransfo); 00111 00112 // SetFromStd -- 00113 // 00114 // Same as "SetFromStdv" except that the standard transformation is 00115 // provided as individual variables instead of a vector. 00116 inline 00117 void SetFromStd (gml_TGRItemParam tx, 00118 gml_TGRItemParam ty, 00119 gml_TGRItemParam r, 00120 gml_TGRItemParam sx, 00121 gml_TGRItemParam sy); 00122 // Transform2v -- 00123 // Transform2 -- 00124 // 00125 // "Transform2v" transforms a 2 dimentional point vector (x, y) <src> 00126 // according to this transformation and stores the result in the 2 dimentional 00127 // point vector <dst>. 00128 // "Tranform2" does the same with a couple of coordinate <x>, <y> and stores the 00129 // result in the couple <xR>, <yR>. 00130 00131 inline 00132 void Transform2v (gml_TGRItemParam* src, gml_TGRItemParam* dst); 00133 inline 00134 void Transform2 (gml_TGRItemParam x, gml_TGRItemParam y, 00135 gml_TGRItemParam& xR, gml_TGRItemParam& yR); 00136 00137 00138 protected: 00139 00140 void UpdateMatrixFromStd (); 00141 void UpdateStdFromMatrix (); 00142 00143 gml_TGRItemParam fMatrix[16]; 00144 gml_TBoolean fMatrixDirty; 00145 gml_TGRItemParam fStd[5]; 00146 gml_TBoolean fStdDirty; 00147 }; 00148 00149 00150 00151 00152 00153 00154 // Inline function definitions 00155 00156 // gml_TGRItemTransfo::Matrix -- 00157 inline 00158 gml_TGRItemParam* gml_TGRItemTransfo::Matrix () 00159 { 00160 if (fMatrixDirty) 00161 this->UpdateMatrixFromStd (); 00162 return fMatrix; 00163 } 00164 00165 // gml_TGRItemTransfo::Stdv -- 00166 inline 00167 gml_TGRItemParam* gml_TGRItemTransfo::Stdv () 00168 { 00169 if (fStdDirty) 00170 this->UpdateStdFromMatrix (); 00171 return fStd; 00172 } 00173 00174 // gml_TGRItemTransfo::GetStd -- 00175 inline 00176 void gml_TGRItemTransfo::GetStd (gml_TGRItemParam& tx, 00177 gml_TGRItemParam& ty, 00178 gml_TGRItemParam& r, 00179 gml_TGRItemParam& sx, 00180 gml_TGRItemParam& sy) 00181 { 00182 if (fStdDirty) 00183 this->UpdateStdFromMatrix (); 00184 00185 tx = fStd[0]; ty = fStd[1]; r = fStd[2]; sx = fStd[3]; sy = fStd[4]; 00186 } 00187 00188 00189 00190 // gml_TGRItemTransfo::CopyTo -- 00191 inline 00192 void gml_TGRItemTransfo::CopyTo (gml_TGRItemTransfo* t) 00193 { 00194 memcpy ((void*)(t->fMatrix), (void*)(this->Matrix ()), sizeof (gml_TGRItemParam) * 16); 00195 t->fMatrixDirty = gml_cFalse; 00196 t->fStdDirty = gml_cTrue; 00197 } 00198 00199 // gml_TGRItemTransfo::SetFromMult -- 00200 inline 00201 void gml_TGRItemTransfo::SetFromMult (gml_TGRItemTransfo* t1, gml_TGRItemTransfo* t2) 00202 { 00203 gml_EM4_MultMxM (t1->Matrix (), t2->Matrix (), fMatrix); 00204 fMatrixDirty = gml_cFalse; 00205 fStdDirty = gml_cTrue; 00206 } 00207 00208 // gml_TGRItemTransfo::SetFromInverse -- 00209 inline 00210 void gml_TGRItemTransfo::SetFromInverse (gml_TGRItemTransfo* t) 00211 { 00212 gml_EM4_Invert (t->Matrix (), fMatrix); 00213 fMatrixDirty = gml_cFalse; 00214 fStdDirty = gml_cTrue; 00215 } 00216 00217 // gml_TGRItemTransfo::SetFromStdv -- 00218 inline 00219 void gml_TGRItemTransfo::SetFromStdv (gml_TGRItemParam* stdTransfo) 00220 { 00221 memcpy ((void*)fStd, (void*)stdTransfo, sizeof (gml_TGRItemParam) * 5); 00222 fMatrixDirty = gml_cTrue; 00223 fStdDirty = gml_cFalse; 00224 } 00225 00226 // gml_TGRItemTransfo::SetFromStd -- 00227 inline 00228 void gml_TGRItemTransfo::SetFromStd (gml_TGRItemParam tx, 00229 gml_TGRItemParam ty, 00230 gml_TGRItemParam r, 00231 gml_TGRItemParam sx, 00232 gml_TGRItemParam sy) 00233 { 00234 fStd[0] = tx; fStd[1] = ty; fStd[2] = r; fStd[3] = sx; fStd[4] = sy; 00235 fMatrixDirty = gml_cTrue; 00236 fStdDirty = gml_cFalse; 00237 } 00238 00239 00240 00241 // gml_TGRItemTransfo::Transform2v -- 00242 00243 inline 00244 void gml_TGRItemTransfo::Transform2v (gml_TGRItemParam* src, gml_TGRItemParam* dst) 00245 { 00246 gml_TGRItemParam src4v[4]; 00247 gml_TGRItemParam dst4v[4]; 00248 00249 src4v[0] = src[0]; 00250 src4v[1] = src[1]; 00251 src4v[2] = 0; 00252 src4v[3] = 1; 00253 00254 gml_EM4_MultMxV (this->Matrix (), src4v, dst4v); 00255 00256 dst[0] = dst4v[0]; 00257 dst[1] = dst4v[1]; 00258 } 00259 00260 // gml_TGRItemTransfo::Transform2 -- 00261 00262 inline 00263 void gml_TGRItemTransfo::Transform2 (gml_TGRItemParam x, gml_TGRItemParam y, 00264 gml_TGRItemParam& xR, gml_TGRItemParam& yR) 00265 { 00266 gml_TGRItemParam src4v[4]; 00267 gml_TGRItemParam dst4v[4]; 00268 00269 src4v[0] = x; 00270 src4v[1] = y; 00271 src4v[2] = 0; 00272 src4v[3] = 1; 00273 00274 gml_EM4_MultMxV (this->Matrix (), src4v, dst4v); 00275 00276 xR = dst4v[0]; 00277 yR = dst4v[1]; 00278 } 00279 00280 #endif
Generated on Tue Jun 12 14:03:27 2007 for gml by
Doxygen 1.5.2.
|
Contact: julien (dot) letessier (at) gmail (dot) com.
Copyright (c) 2000-2007 CLIPS-IMAG Laboratory, Grenoble, France. All rights reserved. W3CXHTML 1.0 W3CCSS 2.0 |