Fawkes API  Fawkes Development Version
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
hom_transform.h
1 
2 /***************************************************************************
3  * hom_transform.h - Homogenous affine transformation
4  *
5  * Created: Wed Sep 26 14:31:42 2007
6  * Copyright 2007-2008 Daniel Beck
7  *
8  ****************************************************************************/
9 
10 /* This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version. A runtime exception applies to
14  * this software (see LICENSE.GPL_WRE file mentioned below for details).
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU Library General Public License for more details.
20  *
21  * Read the full text in the LICENSE.GPL_WRE file in the doc directory.
22  */
23 
24 #ifndef __GEOMETRY_TRANSFORM_H_
25 #define __GEOMETRY_TRANSFORM_H_
26 
27 #include <geometry/matrix.h>
28 
29 namespace fawkes {
30 
32 {
33  public:
34  HomTransform();
35  HomTransform(const HomTransform& ht);
36  HomTransform(const Matrix& m);
37  virtual ~HomTransform();
38 
40  virtual HomTransform& invert();
41  virtual HomTransform get_inverse();
42 
43  void rotate_x(float rad);
44  void rotate_y(float rad);
45  void rotate_z(float rad);
46 
47  void trans(float dx, float dy, float dz = 0.0);
48  void set_trans(float x, float y, float z = 0.0);
49 
50  void mDH(const float alpha, const float a, const float theta, const float d);
51 
53 
54  template <typename T> T operator*(const T& p) const;
56 
57  bool operator==(const HomTransform& t) const;
58 
59  void print_info( const char* name = 0,
60  const char* col_sep = 0,
61  const char* row_sep = 0 ) const;
62 
63  const Matrix& get_matrix() const;
64 
65  private:
66  Matrix* m_matrix;
67 };
68 
69 /** Multiplication operator.
70  * @param p the RHS object
71  * @return the transformed RHS object
72  */
73 template <typename T> inline T HomTransform::operator*(const T& p) const
74  {
75  T result(p);
76  result.transform(*this);
77  return result;
78  }
79 
80 /** Multiplication operator (specialization for HomTransforms)
81  * @param t the RHS HomTransform
82  * @return the result of multiplying the two transforms with each other
83  */
84 template <> inline HomTransform HomTransform::operator*<HomTransform>(const HomTransform& t) const
85  {
86  return HomTransform((*m_matrix) * (*t.m_matrix));
87  }
88 
89 } // end namespace fawkes
90 
91 #endif /* __GEOMETRY_TRANSFORM_H_ */