Fawkes API Fawkes Development Version
|
00001 00002 /*************************************************************************** 00003 * hom_transform.h - Homogenous affine transformation 00004 * 00005 * Created: Wed Sep 26 14:31:42 2007 00006 * Copyright 2007-2008 Daniel Beck 00007 * 00008 ****************************************************************************/ 00009 00010 /* This program is free software; you can redistribute it and/or modify 00011 * it under the terms of the GNU General Public License as published by 00012 * the Free Software Foundation; either version 2 of the License, or 00013 * (at your option) any later version. A runtime exception applies to 00014 * this software (see LICENSE.GPL_WRE file mentioned below for details). 00015 * 00016 * This program is distributed in the hope that it will be useful, 00017 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00019 * GNU Library General Public License for more details. 00020 * 00021 * Read the full text in the LICENSE.GPL_WRE file in the doc directory. 00022 */ 00023 00024 #ifndef __GEOMETRY_TRANSFORM_H_ 00025 #define __GEOMETRY_TRANSFORM_H_ 00026 00027 #include <geometry/matrix.h> 00028 00029 namespace fawkes { 00030 00031 class HomTransform 00032 { 00033 public: 00034 HomTransform(); 00035 HomTransform(const HomTransform& ht); 00036 HomTransform(const Matrix& m); 00037 virtual ~HomTransform(); 00038 00039 HomTransform& reset(); 00040 virtual HomTransform& invert(); 00041 virtual HomTransform get_inverse(); 00042 00043 void rotate_x(float rad); 00044 void rotate_y(float rad); 00045 void rotate_z(float rad); 00046 00047 void trans(float dx, float dy, float dz = 0.0); 00048 void set_trans(float x, float y, float z = 0.0); 00049 00050 void mDH(const float alpha, const float a, const float theta, const float d); 00051 00052 HomTransform& operator=(const HomTransform& t); 00053 00054 template <typename T> T operator*(const T& p) const; 00055 HomTransform& operator*=(const HomTransform& t); 00056 00057 bool operator==(const HomTransform& t) const; 00058 00059 void print_info( const char* name = 0, 00060 const char* col_sep = 0, 00061 const char* row_sep = 0 ) const; 00062 00063 const Matrix& get_matrix() const; 00064 00065 private: 00066 Matrix* m_matrix; 00067 }; 00068 00069 /** Multiplication operator. 00070 * @param p the RHS object 00071 * @return the transformed RHS object 00072 */ 00073 template <typename T> inline T HomTransform::operator*(const T& p) const 00074 { 00075 T result(p); 00076 result.transform(*this); 00077 return result; 00078 } 00079 00080 /** Multiplication operator (specialization for HomTransforms) 00081 * @param t the RHS HomTransform 00082 * @return the result of multiplying the two transforms with each other 00083 */ 00084 template <> inline HomTransform HomTransform::operator*<HomTransform>(const HomTransform& t) const 00085 { 00086 return HomTransform((*m_matrix) * (*t.m_matrix)); 00087 } 00088 00089 } // end namespace fawkes 00090 00091 #endif /* __GEOMETRY_TRANSFORM_H_ */