#include <PositionXformFilter.h>
Inheritance diagram for gadget::PositionXformFilter:


Public Methods | |
| PositionXformFilter () | |
| Constructor. More... | |
| virtual | ~PositionXformFilter () |
| Destructor. More... | |
| virtual bool | config (jccl::ConfigElementPtr e) |
| Configuration for the filter. More... | |
| virtual void | apply (std::vector< PositionData > &posSample) |
| Apply the pos filter. More... | |
Static Public Methods | |
| std::string | getElementType () |
| Returns the string rep of the element type used to config this device. More... | |
Protected Attributes | |
| gmtl::Matrix44f | mPreXform |
| pre transformation. More... | |
| gmtl::Matrix44f | mPostXform |
| post transformation. More... | |
| float | mScaleValue |
| The value to use for scaling. More... | |
compute Sensor = preTrans*preRot*(Scale*Sensor)*postTrans*postRot
Definition at line 53 of file PositionXformFilter.h.
|
|
Constructor.
Definition at line 57 of file PositionXformFilter.h.
00058 : mScaleValue(0.0f) 00059 {;} |
|
|
Destructor.
Definition at line 62 of file PositionXformFilter.h.
00063 {;}
|
|
|
Configuration for the filter.
Implements gadget::PositionFilter. Definition at line 57 of file PositionXformFilter.cpp. References mPostXform, mPreXform, and mScaleValue.
00058 {
00059 vprDEBUG_OutputGuard(vprDBG_ALL, vprDBG_VERB_LVL,
00060 std::string("PositionXformFilter::config: ") +
00061 e->getFullName() + std::string(":") +
00062 e->getID() + std::string("\n"),
00063 std::string("PositionXformFilter::config: done.\n") );
00064
00065 vprASSERT(e->getID() == PositionXformFilter::getElementType());
00066
00067 // These are the transforms from the base tracker coord system
00068 float pre_xt, pre_yt, pre_zt;
00069 float post_xt, post_yt, post_zt;
00070 pre_xt = e->getProperty<float>("pre_translate",0);
00071 pre_yt = e->getProperty<float>("pre_translate",1);
00072 pre_zt = e->getProperty<float>("pre_translate",2);
00073
00074 post_xt = e->getProperty<float>("post_translate",0);
00075 post_yt = e->getProperty<float>("post_translate",1);
00076 post_zt = e->getProperty<float>("post_translate",2);
00077
00078
00079 // These values are specified in human-friendly degrees but must be passed
00080 // to GMTL as radians.
00081 float pre_xr, pre_yr, pre_zr;
00082 float post_xr, post_yr, post_zr;
00083 pre_xr = gmtl::Math::deg2Rad(e->getProperty<float>("pre_rotation",0));
00084 pre_yr = gmtl::Math::deg2Rad(e->getProperty<float>("pre_rotation",1));
00085 pre_zr = gmtl::Math::deg2Rad(e->getProperty<float>("pre_rotation",2));
00086
00087 post_xr = gmtl::Math::deg2Rad(e->getProperty<float>("post_rotation",0));
00088 post_yr = gmtl::Math::deg2Rad(e->getProperty<float>("post_rotation",1));
00089 post_zr = gmtl::Math::deg2Rad(e->getProperty<float>("post_rotation",2));
00090
00091 // Calculate the scale value
00092 // - If dev_units is 0.0f, then use custom_scale
00093 mScaleValue = e->getProperty<float>("device_units");
00094
00095 if(mScaleValue == 0.0f)
00096 {
00097 mScaleValue = e->getProperty<float>("custom_scale");
00098 }
00099
00100 // This makes a rotation matrix that moves a pt in
00101 // the device's coord system to the vj coord system.
00102 // ==> world_M_transmitter
00103 // PRE XFORM
00104 gmtl::Matrix44f pre_trans_mat, pre_rot_mat;
00105 if((0.0f != pre_xt) || (0.0f != pre_yt) || (0.0f != pre_zt))
00106 {
00107 gmtl::setTrans(pre_trans_mat, gmtl::Vec3f(pre_xt, pre_yt, pre_zt) );
00108 }
00109 if((pre_xr != 0.0f) || (pre_yr != 0.0f) || (pre_zr != 0.0f))
00110 {
00111 gmtl::EulerAngleXYZf euler( pre_xr,pre_yr,pre_zr );
00112 pre_rot_mat = gmtl::makeRot<gmtl::Matrix44f>( euler );
00113 }
00114
00115 // POST XFORM
00116 gmtl::Matrix44f post_trans_mat, post_rot_mat;
00117 if((0.0f != post_xt) || (0.0f != post_yt) || (0.0f != post_zt))
00118 {
00119 gmtl::setTrans(post_trans_mat, gmtl::Vec3f(post_xt, post_yt, post_zt) );
00120 }
00121 if((post_xr != 0.0f) || (post_yr != 0.0f) || (post_zr != 0.0f))
00122 {
00123 gmtl::EulerAngleXYZf euler( post_xr,post_yr,post_zr );
00124 post_rot_mat = gmtl::makeRot<gmtl::Matrix44f>( euler );
00125 }
00126
00127 mPreXform = pre_trans_mat;
00128 gmtl::postMult(mPreXform, pre_rot_mat); // xformMat = T*R
00129
00130 mPostXform = post_trans_mat;
00131 gmtl::postMult(mPostXform, post_rot_mat); // xformMat = T*R
00132
00133 vprDEBUG(vprDBG_ALL, vprDBG_VERB_LVL)
00134 << "m:preXform [T*R]: \n" << mPreXform
00135 << "\npre_trans_mat:\n" << pre_trans_mat
00136 << "\npre_rot_mat:\n" << pre_rot_mat
00137 << "\n" << vprDEBUG_FLUSH;
00138 vprDEBUG(vprDBG_ALL, vprDBG_VERB_LVL)
00139 << "m:postXform [T*R]: \n" << mPostXform
00140 << "\npost_trans_mat:\n" << post_trans_mat
00141 << "\npost_rot_mat:\n" << post_rot_mat
00142 << "\n" << vprDEBUG_FLUSH;
00143
00144 return true;
00145 }
|
|
|
Apply the pos filter. Apply the filter to the posSample in place.
Implements gadget::PositionFilter. Definition at line 148 of file PositionXformFilter.cpp. References mPostXform, mPreXform, and mScaleValue.
00149 {
00150 gmtl::Matrix44f* cur_mat(NULL);
00151
00152 for(std::vector<PositionData>::iterator i=posSample.begin(); i != posSample.end(); ++i)
00153 {
00154 cur_mat = &((*i).mPosData);
00155
00156 gmtl::postMult(*cur_mat, mPostXform); // POST xform: cur = cur*postTrans*postRot
00157
00158 gmtl::Vec3f trans; // SCALE:
00159 gmtl::setTrans(trans, *cur_mat); // Get the translational vector
00160 trans *= mScaleValue; // Scale the translation and set the value again
00161 gmtl::setTrans(*cur_mat, trans);
00162
00163 gmtl::preMult(*cur_mat, mPreXform); // PRE: S_world = wMs * S_sensor
00164 }
00165 }
|
|
|
Returns the string rep of the element type used to config this device. This string is used by the device factory to look up device drivers based up the type of element it is trying to load. Reimplemented from gadget::PositionFilter. Definition at line 52 of file PositionXformFilter.cpp.
00053 {
00054 return "position_transform_filter";
00055 }
|
|
|
pre transformation. preXform is the transform from world to sensor (world_M_sensor) postXform is the transform from sensor to sensor' (sensor_M_newsensor) compute Sensor = preTrans*preRot*(Scale*Sensor)*postTrans*postRot Definition at line 89 of file PositionXformFilter.h. |
|
|
post transformation.
Definition at line 90 of file PositionXformFilter.h. |
|
|
The value to use for scaling.
Definition at line 91 of file PositionXformFilter.h. |
1.2.14 written by Dimitri van Heesch,
© 1997-2002