Visual Servoing Platform  version 3.1.0
vpHomogeneousMatrix.h
1 /****************************************************************************
2  *
3  * This file is part of the ViSP software.
4  * Copyright (C) 2005 - 2017 by Inria. All rights reserved.
5  *
6  * This software is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  * See the file LICENSE.txt at the root directory of this source
11  * distribution for additional information about the GNU GPL.
12  *
13  * For using ViSP with software that can not be combined with the GNU
14  * GPL, please contact Inria about acquiring a ViSP Professional
15  * Edition License.
16  *
17  * See http://visp.inria.fr for more information.
18  *
19  * This software was developed at:
20  * Inria Rennes - Bretagne Atlantique
21  * Campus Universitaire de Beaulieu
22  * 35042 Rennes Cedex
23  * France
24  *
25  * If you have questions regarding the use of this file, please contact
26  * Inria at visp@inria.fr
27  *
28  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
29  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
30  *
31  * Description:
32  * Homogeneous matrix.
33  *
34  * Authors:
35  * Eric Marchand
36  *
37  *****************************************************************************/
38 
44 #ifndef VPHOMOGENEOUSMATRIX_HH
45 #define VPHOMOGENEOUSMATRIX_HH
46 
48 class vpPoseVector;
49 class vpMatrix;
50 class vpRotationMatrix;
51 class vpPoseVector;
52 class vpThetaUVector;
53 class vpQuaternionVector;
54 class vpPoint;
55 
56 #include <fstream>
57 #include <vector>
58 
59 #include <visp3/core/vpArray2D.h>
60 #include <visp3/core/vpRotationMatrix.h>
61 #include <visp3/core/vpThetaUVector.h>
62 //#include <visp3/core/vpTranslationVector.h>
63 #include <visp3/core/vpPoseVector.h>
64 
92 class VISP_EXPORT vpHomogeneousMatrix : public vpArray2D<double>
93 {
94 public:
100  explicit vpHomogeneousMatrix(const vpPoseVector &p);
101  explicit vpHomogeneousMatrix(const std::vector<float> &v);
102  explicit vpHomogeneousMatrix(const std::vector<double> &v);
103  vpHomogeneousMatrix(const double tx, const double ty, const double tz, const double tux, const double tuy,
104  const double tuz);
108  virtual ~vpHomogeneousMatrix(){};
109 
110  void buildFrom(const vpTranslationVector &t, const vpRotationMatrix &R);
111  void buildFrom(const vpTranslationVector &t, const vpThetaUVector &tu);
112  void buildFrom(const vpTranslationVector &t, const vpQuaternionVector &q);
113  void buildFrom(const vpPoseVector &p);
114  void buildFrom(const std::vector<float> &v);
115  void buildFrom(const std::vector<double> &v);
116  void buildFrom(const double tx, const double ty, const double tz, const double tux, const double tuy,
117  const double tuz);
118 
119  void convert(std::vector<float> &M);
120  void convert(std::vector<double> &M);
121 
122  // Set to identity
123  void eye();
124 
125  vpColVector getCol(const unsigned int j) const;
126  vpRotationMatrix getRotationMatrix() const;
127  vpThetaUVector getThetaUVector() const;
128  vpTranslationVector getTranslationVector() const;
129 
130  // Invert the homogeneous matrix.
131  vpHomogeneousMatrix inverse() const;
132  // Invert the homogeneous matrix.
133  void inverse(vpHomogeneousMatrix &Mi) const;
134 
135  // Test if the rotational part of the matrix is a rotation matrix.
136  bool isAnHomogeneousMatrix() const;
137 
138  void insert(const vpRotationMatrix &R);
139  void insert(const vpThetaUVector &tu);
140  void insert(const vpTranslationVector &t);
141  void insert(const vpQuaternionVector &t);
142 
143  void extract(vpRotationMatrix &R) const;
144  void extract(vpThetaUVector &tu) const;
145  void extract(vpTranslationVector &t) const;
146  void extract(vpQuaternionVector &q) const;
147 
148  // Load an homogeneous matrix from a file
149  void load(std::ifstream &f);
150  // Save an homogeneous matrix in a file
151  void save(std::ofstream &f) const;
152 
155  vpHomogeneousMatrix &operator*=(const vpHomogeneousMatrix &M);
156 
157  vpColVector operator*(const vpColVector &v) const;
158  vpTranslationVector operator*(const vpTranslationVector &t) const;
159 
160  // Multiply by a point
161  vpPoint operator*(const vpPoint &bP) const;
162 
163  void print() const;
164 
170  void resize(const unsigned int nrows, const unsigned int ncols, const bool flagNullify = true)
171  {
172  (void)nrows;
173  (void)ncols;
174  (void)flagNullify;
175  throw(vpException(vpException::fatalError, "Cannot resize an homogeneous matrix"));
176  };
177 
178 #if defined(VISP_BUILD_DEPRECATED_FUNCTIONS)
179 
187  vp_deprecated void init(){};
191  vp_deprecated void setIdentity();
193 #endif
194 };
195 
196 #endif
197 
198 /*
199  * Local variables:
200  * c-basic-offset: 2
201  * End:
202  */
Implementation of a matrix and operations on matrices.
Definition: vpMatrix.h:104
static bool save(const std::string &filename, const vpArray2D< Type > &A, const bool binary=false, const char *header="")
Definition: vpArray2D.h:508
vpArray2D< Type > & operator=(Type x)
Set all the elements of the array to x.
Definition: vpArray2D.h:244
Implementation of an homogeneous matrix and operations on such kind of matrices.
error that can be emited by ViSP classes.
Definition: vpException.h:71
Implementation of a generic 2D array used as vase class of matrices and vectors.
Definition: vpArray2D.h:70
Class that defines what is a point.
Definition: vpPoint.h:58
Implementation of a rotation matrix and operations on such kind of matrices.
vpColVector operator*(const double &x, const vpColVector &v)
void resize(const unsigned int nrows, const unsigned int ncols, const bool flagNullify=true)
vp_deprecated void init()
static bool load(const std::string &filename, vpArray2D< Type > &A, const bool binary=false, char *header=NULL)
Definition: vpArray2D.h:318
Implementation of a rotation vector as quaternion angle minimal representation.
Implementation of column vector and the associated operations.
Definition: vpColVector.h:72
Implementation of a pose vector and operations on poses.
Definition: vpPoseVector.h:92
Class that consider the case of a translation vector.
Implementation of a rotation vector as axis-angle minimal representation.