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